diff options
author | Charles Lombardo <clombardo169@gmail.com> | 2023-10-29 19:15:37 +0100 |
---|---|---|
committer | Charles Lombardo <clombardo169@gmail.com> | 2023-10-30 02:29:32 +0100 |
commit | 25815900236c45a340feb7654b6d49792c10c4f4 (patch) | |
tree | 653bb69ded0b4b2cbdb03a96ead617484e13d3df /src | |
parent | Merge pull request #11866 from liamwhite/more-qt-nonsense (diff) | |
download | yuzu-25815900236c45a340feb7654b6d49792c10c4f4.tar yuzu-25815900236c45a340feb7654b6d49792c10c4f4.tar.gz yuzu-25815900236c45a340feb7654b6d49792c10c4f4.tar.bz2 yuzu-25815900236c45a340feb7654b6d49792c10c4f4.tar.lz yuzu-25815900236c45a340feb7654b6d49792c10c4f4.tar.xz yuzu-25815900236c45a340feb7654b6d49792c10c4f4.tar.zst yuzu-25815900236c45a340feb7654b6d49792c10c4f4.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt | 39 |
1 files changed, 23 insertions, 16 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 6e09fa81d..004b25b04 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 @@ -49,26 +49,33 @@ class GamesViewModel : ViewModel() { // Retrieve list of cached games val storedGames = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext) .getStringSet(GameHelper.KEY_GAMES, emptySet()) - if (storedGames!!.isNotEmpty()) { - val deserializedGames = mutableSetOf<Game>() - storedGames.forEach { - val game: Game - try { - game = Json.decodeFromString(it) - } catch (e: MissingFieldException) { - return@forEach - } - val gameExists = - DocumentFile.fromSingleUri(YuzuApplication.appContext, Uri.parse(game.path)) - ?.exists() - if (gameExists == true) { - deserializedGames.add(game) + viewModelScope.launch { + withContext(Dispatchers.IO) { + if (storedGames!!.isNotEmpty()) { + val deserializedGames = mutableSetOf<Game>() + storedGames.forEach { + val game: Game + try { + game = Json.decodeFromString(it) + } catch (e: MissingFieldException) { + return@forEach + } + + val gameExists = + DocumentFile.fromSingleUri( + YuzuApplication.appContext, + Uri.parse(game.path) + )?.exists() + if (gameExists == true) { + deserializedGames.add(game) + } + } + setGames(deserializedGames.toList()) } + reloadGames(false) } - setGames(deserializedGames.toList()) } - reloadGames(false) } fun setGames(games: List<Game>) { |