mirror of
				https://git.tardis.systems/mirrors/yuzu
				synced 2025-10-31 18:54:14 +01:00 
			
		
		
		
	Merge pull request #11915 from t895/startup-freeze
android: Move game deserialization to another thread
This commit is contained in:
		
						commit
						789c16305d
					
				| @ -49,6 +49,9 @@ class GamesViewModel : ViewModel() { | ||||
|         // Retrieve list of cached games | ||||
|         val storedGames = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext) | ||||
|             .getStringSet(GameHelper.KEY_GAMES, emptySet()) | ||||
| 
 | ||||
|         viewModelScope.launch { | ||||
|             withContext(Dispatchers.IO) { | ||||
|                 if (storedGames!!.isNotEmpty()) { | ||||
|                     val deserializedGames = mutableSetOf<Game>() | ||||
|                     storedGames.forEach { | ||||
| @ -60,8 +63,10 @@ class GamesViewModel : ViewModel() { | ||||
|                         } | ||||
| 
 | ||||
|                         val gameExists = | ||||
|                     DocumentFile.fromSingleUri(YuzuApplication.appContext, Uri.parse(game.path)) | ||||
|                         ?.exists() | ||||
|                             DocumentFile.fromSingleUri( | ||||
|                                 YuzuApplication.appContext, | ||||
|                                 Uri.parse(game.path) | ||||
|                             )?.exists() | ||||
|                         if (gameExists == true) { | ||||
|                             deserializedGames.add(game) | ||||
|                         } | ||||
| @ -70,6 +75,8 @@ class GamesViewModel : ViewModel() { | ||||
|                 } | ||||
|                 reloadGames(false) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     fun setGames(games: List<Game>) { | ||||
|         val sortedList = games.sortedWith( | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user