Merge pull request #9529 from JosJuice/android-broadcast-before-metadata

Android: Broadcast update before updating additional metadata
This commit is contained in:
Léo Lam 2021-03-05 00:48:04 +01:00 committed by GitHub
commit 19c5a19629
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 12 deletions

View File

@ -99,7 +99,7 @@ public class GameFileCache
* *
* @return true if the cache was modified * @return true if the cache was modified
*/ */
public boolean scanLibrary() public boolean update()
{ {
boolean recursiveScan = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBooleanGlobal(); boolean recursiveScan = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBooleanGlobal();
@ -107,13 +107,7 @@ public class GameFileCache
String[] folderPaths = folderPathsSet.toArray(new String[0]); String[] folderPaths = folderPathsSet.toArray(new String[0]);
boolean cacheChanged = update(folderPaths, recursiveScan); return update(folderPaths, recursiveScan);
cacheChanged |= updateAdditionalMetadata();
if (cacheChanged)
{
save();
}
return cacheChanged;
} }
public native int getSize(); public native int getSize();
@ -122,11 +116,11 @@ public class GameFileCache
public native GameFile addOrGet(String gamePath); 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(); public native boolean load();
private native boolean save(); public native boolean save();
} }

View File

@ -177,12 +177,24 @@ public final class GameFileCacheService extends IntentService
{ {
synchronized (gameFileCache) synchronized (gameFileCache)
{ {
boolean changed = gameFileCache.scanLibrary(); boolean changed = gameFileCache.update();
if (changed) if (changed)
{ {
updateGameFileArray(); updateGameFileArray();
sendBroadcast(CACHE_UPDATED); sendBroadcast(CACHE_UPDATED);
} }
boolean additionalMetadataChanged = gameFileCache.updateAdditionalMetadata();
if (additionalMetadataChanged)
{
updateGameFileArray();
sendBroadcast(CACHE_UPDATED);
}
if (changed || additionalMetadataChanged)
{
gameFileCache.save();
}
} }
} }