diff options
author | Charles Lombardo <clombardo169@gmail.com> | 2023-09-27 00:28:40 +0200 |
---|---|---|
committer | Charles Lombardo <clombardo169@gmail.com> | 2023-09-27 19:40:09 +0200 |
commit | 1fdfedc43eb4cb031d529f3f3c20b0642247d5c2 (patch) | |
tree | 1e474ffb5538e861a47d8179ff14cfaa37bc0ecd /src/android/app | |
parent | Merge pull request #11602 from t895/case-fix (diff) | |
download | yuzu-1fdfedc43eb4cb031d529f3f3c20b0642247d5c2.tar yuzu-1fdfedc43eb4cb031d529f3f3c20b0642247d5c2.tar.gz yuzu-1fdfedc43eb4cb031d529f3f3c20b0642247d5c2.tar.bz2 yuzu-1fdfedc43eb4cb031d529f3f3c20b0642247d5c2.tar.lz yuzu-1fdfedc43eb4cb031d529f3f3c20b0642247d5c2.tar.xz yuzu-1fdfedc43eb4cb031d529f3f3c20b0642247d5c2.tar.zst yuzu-1fdfedc43eb4cb031d529f3f3c20b0642247d5c2.zip |
Diffstat (limited to 'src/android/app')
-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 import android.os.Looper import android.view.* import android.widget.TextView +import android.widget.Toast import androidx.activity.OnBackPressedCallback import androidx.appcompat.widget.PopupMenu import androidx.core.content.res.ResourcesCompat @@ -53,6 +54,7 @@ import org.yuzu.yuzu_emu.model.Game import org.yuzu.yuzu_emu.model.EmulationViewModel import org.yuzu.yuzu_emu.overlay.InputOverlay import org.yuzu.yuzu_emu.utils.* +import java.lang.NullPointerException class EmulationFragment : Fragment(), SurfaceHolder.Callback { private lateinit var preferences: SharedPreferences @@ -104,10 +106,21 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { null } } - game = if (args.game != null) { - args.game!! - } else { - intentGame ?: error("[EmulationFragment] No bootable game present!") + + try { + game = if (args.game != null) { + args.game!! + } else { + intentGame!! + } + } catch (e: NullPointerException) { + Toast.makeText( + requireContext(), + R.string.no_game_present, + Toast.LENGTH_SHORT + ).show() + requireActivity().finish() + return } // So this fragment doesn't restart on configuration changes; i.e. rotation. @@ -131,6 +144,11 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { // This is using the correct scope, lint is just acting up @SuppressLint("UnsafeRepeatOnLifecycleDetector") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + if (requireActivity().isFinishing) { + return + } + binding.surfaceEmulation.holder.addCallback(this) binding.showFpsText.setTextColor(Color.YELLOW) 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 @@ <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> <string name="device_memory_inadequate">Device RAM: %1$s\nRecommended: %2$s</string> <string name="memory_formatted">%1$s %2$s</string> + <string name="no_game_present">No bootable game present!</string> <!-- Region Names --> <string name="region_japan">Japan</string> |