From 873d5f985209939e2518ff694394bfc1c33cc796 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 20 Feb 2021 19:58:44 +0100 Subject: [PATCH] Android: Broadcast update before updating additional metadata In master, the game scanning process looks like this: 1. Scan for games 2. Scan for additional metadata (icon.png and meta.xml) 3. Save the cache if needed 4. Update the game list with the results This change makes the game scanning process look like this: 1. Scan for games 2. Update the game list with the results 3. Scan for additional metadata (icon.png and meta.xml) 4. Update the game list with the results 5. Save the cache if needed Updating the game list as soon as possible means the user has to wait less before their games show up. The new behavior matches what DolphinWX did before it was removed. (DolphinQt has an even fancier approach where games get added one by one.) --- .../dolphinemu/model/GameFileCache.java | 16 +++++----------- .../services/GameFileCacheService.java | 14 +++++++++++++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.java index e359d701bc..cca12267b2 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.java @@ -99,7 +99,7 @@ public class GameFileCache * * @return true if the cache was modified */ - public boolean scanLibrary() + public boolean update() { boolean recursiveScan = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBooleanGlobal(); @@ -107,13 +107,7 @@ public class GameFileCache String[] folderPaths = folderPathsSet.toArray(new String[0]); - boolean cacheChanged = update(folderPaths, recursiveScan); - cacheChanged |= updateAdditionalMetadata(); - if (cacheChanged) - { - save(); - } - return cacheChanged; + return update(folderPaths, recursiveScan); } public native int getSize(); @@ -122,11 +116,11 @@ public class GameFileCache public native GameFile addOrGet(String gamePath); - private native boolean update(String[] folderPaths, boolean recursiveScan); + public native boolean update(String[] folderPaths, boolean recursiveScan); - private native boolean updateAdditionalMetadata(); + public native boolean updateAdditionalMetadata(); public native boolean load(); - private native boolean save(); + public native boolean save(); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheService.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheService.java index 34bf1afa0a..0abd072467 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheService.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheService.java @@ -177,12 +177,24 @@ public final class GameFileCacheService extends IntentService { synchronized (gameFileCache) { - boolean changed = gameFileCache.scanLibrary(); + boolean changed = gameFileCache.update(); if (changed) { updateGameFileArray(); sendBroadcast(CACHE_UPDATED); } + + boolean additionalMetadataChanged = gameFileCache.updateAdditionalMetadata(); + if (additionalMetadataChanged) + { + updateGameFileArray(); + sendBroadcast(CACHE_UPDATED); + } + + if (changed || additionalMetadataChanged) + { + gameFileCache.save(); + } } }