Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11680 from t895/long-press-fix
Android: Long press leanback game card fix
  • Loading branch information
JosJuice committed Mar 22, 2023
2 parents 4ae4a28 + ce66d58 commit 66e4141
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Expand Up @@ -17,6 +17,7 @@ import org.dolphinemu.dolphinemu.activities.EmulationActivity
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.dolphinemu.dolphinemu.databinding.CardGameBinding
import org.dolphinemu.dolphinemu.dialogs.GamePropertiesDialog
Expand Down Expand Up @@ -72,7 +73,7 @@ class GameAdapter(private val mActivity: FragmentActivity) : RecyclerView.Adapte
}
}

mActivity.lifecycleScope.launchWhenStarted {
mActivity.lifecycleScope.launch {
withContext(Dispatchers.IO) {
val customCoverUri = CoilUtils.findCustomCover(gameFile)
withContext(Dispatchers.Main) {
Expand Down
Expand Up @@ -15,6 +15,7 @@ import android.widget.ImageView
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.dolphinemu.dolphinemu.dialogs.GamePropertiesDialog
import org.dolphinemu.dolphinemu.utils.CoilUtils
Expand Down Expand Up @@ -53,11 +54,12 @@ class GameRowPresenter(private val mActivity: FragmentActivity) : Presenter() {
// Set the background color of the card
val background = ContextCompat.getDrawable(context, R.drawable.tv_card_background)
cardParent.infoAreaBackground = background
cardParent.setOnClickListener { view: View ->
cardParent.setOnLongClickListener { view: View ->
val activity = view.context as FragmentActivity
val fragment = GamePropertiesDialog.newInstance(holder.gameFile)
activity.supportFragmentManager.beginTransaction()
.add(fragment, GamePropertiesDialog.TAG).commit()
true
}

if (GameFileCacheManager.findSecondDisc(gameFile) != null) {
Expand All @@ -68,7 +70,7 @@ class GameRowPresenter(private val mActivity: FragmentActivity) : Presenter() {
}
}

mActivity.lifecycleScope.launchWhenStarted {
mActivity.lifecycleScope.launch {
withContext(Dispatchers.IO) {
val customCoverUri = CoilUtils.findCustomCover(gameFile)
withContext(Dispatchers.Main) {
Expand Down
Expand Up @@ -24,6 +24,7 @@ import com.google.android.material.color.MaterialColors
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.elevation.ElevationOverlayProvider
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.dolphinemu.dolphinemu.R
import org.dolphinemu.dolphinemu.databinding.ActivityCheatsBinding
Expand Down Expand Up @@ -171,7 +172,7 @@ class CheatsActivity : AppCompatActivity(), PanelSlideListener {
.setCancelable(false)
.show()

lifecycleScope.launchWhenResumed {
lifecycleScope.launch {
withContext(Dispatchers.IO) {
val codes = downloadCodes(gameTdbId!!)
withContext(Dispatchers.Main) {
Expand Down

0 comments on commit 66e4141

Please sign in to comment.