mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
android: Check if cached games are valid
Fixes bug when you close yuzu, delete games, and reopen to an instant crash.
This commit is contained in:
parent
aa957df0dc
commit
bafd4d344f
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
package org.yuzu.yuzu_emu.model
|
package org.yuzu.yuzu_emu.model
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
import androidx.documentfile.provider.DocumentFile
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
@ -44,7 +46,13 @@ class GamesViewModel : ViewModel() {
|
||||||
if (storedGames!!.isNotEmpty()) {
|
if (storedGames!!.isNotEmpty()) {
|
||||||
val deserializedGames = mutableSetOf<Game>()
|
val deserializedGames = mutableSetOf<Game>()
|
||||||
storedGames.forEach {
|
storedGames.forEach {
|
||||||
deserializedGames.add(Json.decodeFromString(it))
|
val game: Game = Json.decodeFromString(it)
|
||||||
|
val gameExists =
|
||||||
|
DocumentFile.fromSingleUri(YuzuApplication.appContext, Uri.parse(game.path))
|
||||||
|
?.exists()
|
||||||
|
if (gameExists == true) {
|
||||||
|
deserializedGames.add(game)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setGames(deserializedGames.toList())
|
setGames(deserializedGames.toList())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue