summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Charles Lombardo2023-09-26 13:27:28 -0400
committerGravatar Charles Lombardo2023-09-26 13:27:28 -0400
commit95a31b8887c2cfdf6f0ff0beb0bbf9f5c47b81f9 (patch)
tree74247b02a0dfe1c102ee704cb2cf1d306730b375
parentandroid: Refactor zip code into FileUtil (diff)
downloadyuzu-95a31b8887c2cfdf6f0ff0beb0bbf9f5c47b81f9.tar.gz
yuzu-95a31b8887c2cfdf6f0ff0beb0bbf9f5c47b81f9.tar.xz
yuzu-95a31b8887c2cfdf6f0ff0beb0bbf9f5c47b81f9.zip
android: Fix cancel behavior on indeterminate progress dialog fragment
The dialog would previously dismiss immediately when it should stay alive until the task is cancelled completely.
Diffstat (limited to '')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/IndeterminateProgressDialogFragment.kt18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/IndeterminateProgressDialogFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/IndeterminateProgressDialogFragment.kt
index 0d16a7d37..f128deda8 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/IndeterminateProgressDialogFragment.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/IndeterminateProgressDialogFragment.kt
@@ -4,12 +4,12 @@
4package org.yuzu.yuzu_emu.fragments 4package org.yuzu.yuzu_emu.fragments
5 5
6import android.app.Dialog 6import android.app.Dialog
7import android.content.DialogInterface
8import android.os.Bundle 7import android.os.Bundle
9import android.view.LayoutInflater 8import android.view.LayoutInflater
10import android.view.View 9import android.view.View
11import android.view.ViewGroup 10import android.view.ViewGroup
12import android.widget.Toast 11import android.widget.Toast
12import androidx.appcompat.app.AlertDialog
13import androidx.appcompat.app.AppCompatActivity 13import androidx.appcompat.app.AppCompatActivity
14import androidx.fragment.app.DialogFragment 14import androidx.fragment.app.DialogFragment
15import androidx.fragment.app.activityViewModels 15import androidx.fragment.app.activityViewModels
@@ -39,9 +39,7 @@ class IndeterminateProgressDialogFragment : DialogFragment() {
39 .setView(binding.root) 39 .setView(binding.root)
40 40
41 if (cancellable) { 41 if (cancellable) {
42 dialog.setNegativeButton(android.R.string.cancel) { _: DialogInterface, _: Int -> 42 dialog.setNegativeButton(android.R.string.cancel, null)
43 taskViewModel.setCancelled(true)
44 }
45 } 43 }
46 44
47 val alertDialog = dialog.create() 45 val alertDialog = dialog.create()
@@ -98,6 +96,18 @@ class IndeterminateProgressDialogFragment : DialogFragment() {
98 } 96 }
99 } 97 }
100 98
99 // By default, the ProgressDialog will immediately dismiss itself upon a button being pressed.
100 // Setting the OnClickListener again after the dialog is shown overrides this behavior.
101 override fun onResume() {
102 super.onResume()
103 val alertDialog = dialog as AlertDialog
104 val negativeButton = alertDialog.getButton(Dialog.BUTTON_NEGATIVE)
105 negativeButton.setOnClickListener {
106 alertDialog.setTitle(getString(R.string.cancelling))
107 taskViewModel.setCancelled(true)
108 }
109 }
110
101 companion object { 111 companion object {
102 const val TAG = "IndeterminateProgressDialogFragment" 112 const val TAG = "IndeterminateProgressDialogFragment"
103 113