diff options
| author | 2023-05-11 16:57:13 -0400 | |
|---|---|---|
| committer | 2023-06-03 00:06:01 -0700 | |
| commit | bafd4d344f455c4f4a790a73766b9beaecd6a2f0 (patch) | |
| tree | 4144c29cd4ec10a7241e5bb601d90bad6dde2232 /src/android | |
| parent | android: Invert rotation to match phone orientation (diff) | |
| download | yuzu-bafd4d344f455c4f4a790a73766b9beaecd6a2f0.tar.gz yuzu-bafd4d344f455c4f4a790a73766b9beaecd6a2f0.tar.xz yuzu-bafd4d344f455c4f4a790a73766b9beaecd6a2f0.zip | |
android: Check if cached games are valid
Fixes bug when you close yuzu, delete games, and reopen to an instant crash.
Diffstat (limited to 'src/android')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt index 5a35b14c9..d4de7a09a 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt | |||
| @@ -3,6 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | package org.yuzu.yuzu_emu.model | 4 | package org.yuzu.yuzu_emu.model |
| 5 | 5 | ||
| 6 | import android.net.Uri | ||
| 7 | import androidx.documentfile.provider.DocumentFile | ||
| 6 | import androidx.lifecycle.LiveData | 8 | import androidx.lifecycle.LiveData |
| 7 | import androidx.lifecycle.MutableLiveData | 9 | import androidx.lifecycle.MutableLiveData |
| 8 | import androidx.lifecycle.ViewModel | 10 | import androidx.lifecycle.ViewModel |
| @@ -44,7 +46,13 @@ class GamesViewModel : ViewModel() { | |||
| 44 | if (storedGames!!.isNotEmpty()) { | 46 | if (storedGames!!.isNotEmpty()) { |
| 45 | val deserializedGames = mutableSetOf<Game>() | 47 | val deserializedGames = mutableSetOf<Game>() |
| 46 | storedGames.forEach { | 48 | storedGames.forEach { |
| 47 | deserializedGames.add(Json.decodeFromString(it)) | 49 | val game: Game = Json.decodeFromString(it) |
| 50 | val gameExists = | ||
| 51 | DocumentFile.fromSingleUri(YuzuApplication.appContext, Uri.parse(game.path)) | ||
| 52 | ?.exists() | ||
| 53 | if (gameExists == true) { | ||
| 54 | deserializedGames.add(game) | ||
| 55 | } | ||
| 48 | } | 56 | } |
| 49 | setGames(deserializedGames.toList()) | 57 | setGames(deserializedGames.toList()) |
| 50 | } | 58 | } |