summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
authorGravatar Charles Lombardo2023-05-22 18:32:18 -0400
committerGravatar bunnei2023-06-03 00:06:03 -0700
commit5dbf842a46a68de87471c3f8e265f284ebc2c362 (patch)
tree3a5bc0415ee8c9658dee42d443f7a906a6478e19 /src/android
parentandroid: Clean up dependencies (diff)
downloadyuzu-5dbf842a46a68de87471c3f8e265f284ebc2c362.tar.gz
yuzu-5dbf842a46a68de87471c3f8e265f284ebc2c362.tar.xz
yuzu-5dbf842a46a68de87471c3f8e265f284ebc2c362.zip
android: Improve missing game handling
Previously the app would crash if you selected a game that no longer existed. Now we show an error message and reload the games list to remove any invalid games from the list.
Diffstat (limited to 'src/android')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt19
-rw-r--r--src/android/app/src/main/res/values/strings.xml1
2 files changed, 19 insertions, 1 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt
index a9653475f..7f9e2e2d4 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt
@@ -3,15 +3,18 @@
3 3
4package org.yuzu.yuzu_emu.adapters 4package org.yuzu.yuzu_emu.adapters
5 5
6import android.annotation.SuppressLint
7import android.graphics.Bitmap 6import android.graphics.Bitmap
8import android.graphics.BitmapFactory 7import android.graphics.BitmapFactory
8import android.net.Uri
9import android.text.TextUtils 9import android.text.TextUtils
10import android.view.LayoutInflater 10import android.view.LayoutInflater
11import android.view.View 11import android.view.View
12import android.view.ViewGroup 12import android.view.ViewGroup
13import android.widget.ImageView 13import android.widget.ImageView
14import android.widget.Toast
14import androidx.appcompat.app.AppCompatActivity 15import androidx.appcompat.app.AppCompatActivity
16import androidx.documentfile.provider.DocumentFile
17import androidx.lifecycle.ViewModelProvider
15import androidx.lifecycle.lifecycleScope 18import androidx.lifecycle.lifecycleScope
16import androidx.preference.PreferenceManager 19import androidx.preference.PreferenceManager
17import androidx.recyclerview.widget.AsyncDifferConfig 20import androidx.recyclerview.widget.AsyncDifferConfig
@@ -27,6 +30,7 @@ import org.yuzu.yuzu_emu.databinding.CardGameBinding
27import org.yuzu.yuzu_emu.activities.EmulationActivity 30import org.yuzu.yuzu_emu.activities.EmulationActivity
28import org.yuzu.yuzu_emu.model.Game 31import org.yuzu.yuzu_emu.model.Game
29import org.yuzu.yuzu_emu.adapters.GameAdapter.GameViewHolder 32import org.yuzu.yuzu_emu.adapters.GameAdapter.GameViewHolder
33import org.yuzu.yuzu_emu.model.GamesViewModel
30 34
31class GameAdapter(private val activity: AppCompatActivity) : 35class GameAdapter(private val activity: AppCompatActivity) :
32 ListAdapter<Game, GameViewHolder>(AsyncDifferConfig.Builder(DiffCallback()).build()), 36 ListAdapter<Game, GameViewHolder>(AsyncDifferConfig.Builder(DiffCallback()).build()),
@@ -53,6 +57,19 @@ class GameAdapter(private val activity: AppCompatActivity) :
53 */ 57 */
54 override fun onClick(view: View) { 58 override fun onClick(view: View) {
55 val holder = view.tag as GameViewHolder 59 val holder = view.tag as GameViewHolder
60
61 val gameExists = DocumentFile.fromSingleUri(YuzuApplication.appContext, Uri.parse(holder.game.path))?.exists() == true
62 if (!gameExists) {
63 Toast.makeText(
64 YuzuApplication.appContext,
65 R.string.loader_error_file_not_found,
66 Toast.LENGTH_LONG
67 ).show()
68
69 ViewModelProvider(activity)[GamesViewModel::class.java].reloadGames(true)
70 return
71 }
72
56 val preferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext) 73 val preferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
57 preferences.edit() 74 preferences.edit()
58 .putLong( 75 .putLong(
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml
index e171cf799..03a5ffc7e 100644
--- a/src/android/app/src/main/res/values/strings.xml
+++ b/src/android/app/src/main/res/values/strings.xml
@@ -177,6 +177,7 @@
177 <string name="loader_error_video_core">An error occurred initializing the video core</string> 177 <string name="loader_error_video_core">An error occurred initializing the video core</string>
178 <string name="loader_error_video_core_description">This is usually caused by an incompatible GPU driver. Installing a custom GPU driver may resolve this problem.</string> 178 <string name="loader_error_video_core_description">This is usually caused by an incompatible GPU driver. Installing a custom GPU driver may resolve this problem.</string>
179 <string name="loader_error_invalid_format">Unable to load ROM</string> 179 <string name="loader_error_invalid_format">Unable to load ROM</string>
180 <string name="loader_error_file_not_found">ROM file does not exist</string>
180 181
181 <!-- Emulation Menu --> 182 <!-- Emulation Menu -->
182 <string name="emulation_exit">Exit Emulation</string> 183 <string name="emulation_exit">Exit Emulation</string>