diff options
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/IndeterminateProgressDialogFragment.kt | 18 |
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 @@ | |||
| 4 | package org.yuzu.yuzu_emu.fragments | 4 | package org.yuzu.yuzu_emu.fragments |
| 5 | 5 | ||
| 6 | import android.app.Dialog | 6 | import android.app.Dialog |
| 7 | import android.content.DialogInterface | ||
| 8 | import android.os.Bundle | 7 | import android.os.Bundle |
| 9 | import android.view.LayoutInflater | 8 | import android.view.LayoutInflater |
| 10 | import android.view.View | 9 | import android.view.View |
| 11 | import android.view.ViewGroup | 10 | import android.view.ViewGroup |
| 12 | import android.widget.Toast | 11 | import android.widget.Toast |
| 12 | import androidx.appcompat.app.AlertDialog | ||
| 13 | import androidx.appcompat.app.AppCompatActivity | 13 | import androidx.appcompat.app.AppCompatActivity |
| 14 | import androidx.fragment.app.DialogFragment | 14 | import androidx.fragment.app.DialogFragment |
| 15 | import androidx.fragment.app.activityViewModels | 15 | import 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 | ||