diff options
| author | 2023-09-26 18:28:40 -0400 | |
|---|---|---|
| committer | 2023-09-27 13:40:09 -0400 | |
| commit | 1fdfedc43eb4cb031d529f3f3c20b0642247d5c2 (patch) | |
| tree | 1e474ffb5538e861a47d8179ff14cfaa37bc0ecd /src | |
| parent | Merge pull request #11602 from t895/case-fix (diff) | |
| download | yuzu-1fdfedc43eb4cb031d529f3f3c20b0642247d5c2.tar.gz yuzu-1fdfedc43eb4cb031d529f3f3c20b0642247d5c2.tar.xz yuzu-1fdfedc43eb4cb031d529f3f3c20b0642247d5c2.zip | |
android: Close activity with toast if emulation has no game
Diffstat (limited to '')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt | 26 | ||||
| -rw-r--r-- | src/android/app/src/main/res/values/strings.xml | 1 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index 750638bc9..aa9cea442 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt | |||
| @@ -17,6 +17,7 @@ import android.os.Handler | |||
| 17 | import android.os.Looper | 17 | import android.os.Looper |
| 18 | import android.view.* | 18 | import android.view.* |
| 19 | import android.widget.TextView | 19 | import android.widget.TextView |
| 20 | import android.widget.Toast | ||
| 20 | import androidx.activity.OnBackPressedCallback | 21 | import androidx.activity.OnBackPressedCallback |
| 21 | import androidx.appcompat.widget.PopupMenu | 22 | import androidx.appcompat.widget.PopupMenu |
| 22 | import androidx.core.content.res.ResourcesCompat | 23 | import androidx.core.content.res.ResourcesCompat |
| @@ -53,6 +54,7 @@ import org.yuzu.yuzu_emu.model.Game | |||
| 53 | import org.yuzu.yuzu_emu.model.EmulationViewModel | 54 | import org.yuzu.yuzu_emu.model.EmulationViewModel |
| 54 | import org.yuzu.yuzu_emu.overlay.InputOverlay | 55 | import org.yuzu.yuzu_emu.overlay.InputOverlay |
| 55 | import org.yuzu.yuzu_emu.utils.* | 56 | import org.yuzu.yuzu_emu.utils.* |
| 57 | import java.lang.NullPointerException | ||
| 56 | 58 | ||
| 57 | class EmulationFragment : Fragment(), SurfaceHolder.Callback { | 59 | class EmulationFragment : Fragment(), SurfaceHolder.Callback { |
| 58 | private lateinit var preferences: SharedPreferences | 60 | private lateinit var preferences: SharedPreferences |
| @@ -104,10 +106,21 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 104 | null | 106 | null |
| 105 | } | 107 | } |
| 106 | } | 108 | } |
| 107 | game = if (args.game != null) { | 109 | |
| 108 | args.game!! | 110 | try { |
| 109 | } else { | 111 | game = if (args.game != null) { |
| 110 | intentGame ?: error("[EmulationFragment] No bootable game present!") | 112 | args.game!! |
| 113 | } else { | ||
| 114 | intentGame!! | ||
| 115 | } | ||
| 116 | } catch (e: NullPointerException) { | ||
| 117 | Toast.makeText( | ||
| 118 | requireContext(), | ||
| 119 | R.string.no_game_present, | ||
| 120 | Toast.LENGTH_SHORT | ||
| 121 | ).show() | ||
| 122 | requireActivity().finish() | ||
| 123 | return | ||
| 111 | } | 124 | } |
| 112 | 125 | ||
| 113 | // So this fragment doesn't restart on configuration changes; i.e. rotation. | 126 | // So this fragment doesn't restart on configuration changes; i.e. rotation. |
| @@ -131,6 +144,11 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 131 | // This is using the correct scope, lint is just acting up | 144 | // This is using the correct scope, lint is just acting up |
| 132 | @SuppressLint("UnsafeRepeatOnLifecycleDetector") | 145 | @SuppressLint("UnsafeRepeatOnLifecycleDetector") |
| 133 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | 146 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
| 147 | super.onViewCreated(view, savedInstanceState) | ||
| 148 | if (requireActivity().isFinishing) { | ||
| 149 | return | ||
| 150 | } | ||
| 151 | |||
| 134 | binding.surfaceEmulation.holder.addCallback(this) | 152 | binding.surfaceEmulation.holder.addCallback(this) |
| 135 | binding.showFpsText.setTextColor(Color.YELLOW) | 153 | binding.showFpsText.setTextColor(Color.YELLOW) |
| 136 | binding.doneControlConfig.setOnClickListener { stopConfiguringControls() } | 154 | binding.doneControlConfig.setOnClickListener { stopConfiguringControls() } |
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 574290479..034761401 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml | |||
| @@ -294,6 +294,7 @@ | |||
| 294 | <string name="performance_warning">Turning off this setting will significantly reduce emulation performance! For the best experience, it is recommended that you leave this setting enabled.</string> | 294 | <string name="performance_warning">Turning off this setting will significantly reduce emulation performance! For the best experience, it is recommended that you leave this setting enabled.</string> |
| 295 | <string name="device_memory_inadequate">Device RAM: %1$s\nRecommended: %2$s</string> | 295 | <string name="device_memory_inadequate">Device RAM: %1$s\nRecommended: %2$s</string> |
| 296 | <string name="memory_formatted">%1$s %2$s</string> | 296 | <string name="memory_formatted">%1$s %2$s</string> |
| 297 | <string name="no_game_present">No bootable game present!</string> | ||
| 297 | 298 | ||
| 298 | <!-- Region Names --> | 299 | <!-- Region Names --> |
| 299 | <string name="region_japan">Japan</string> | 300 | <string name="region_japan">Japan</string> |