Android: Use config changed callback for tracking recursive scan setting
This way the Settings class doesn't contain a hardcoded reference to a specific setting. And Settings.loadSettings no longer calls getBoolean, which is a step towards fixing the crash when recreating EmulationActivity after process death.
This commit is contained in:
parent
d80f9d53fc
commit
3e7a16f225
|
@ -8,7 +8,6 @@ import android.widget.Toast
|
||||||
import org.dolphinemu.dolphinemu.NativeLibrary
|
import org.dolphinemu.dolphinemu.NativeLibrary
|
||||||
import org.dolphinemu.dolphinemu.R
|
import org.dolphinemu.dolphinemu.R
|
||||||
import org.dolphinemu.dolphinemu.features.input.model.MappingCommon
|
import org.dolphinemu.dolphinemu.features.input.model.MappingCommon
|
||||||
import org.dolphinemu.dolphinemu.services.GameFileCacheManager
|
|
||||||
import java.io.Closeable
|
import java.io.Closeable
|
||||||
|
|
||||||
class Settings : Closeable {
|
class Settings : Closeable {
|
||||||
|
@ -19,7 +18,6 @@ class Settings : Closeable {
|
||||||
private set
|
private set
|
||||||
|
|
||||||
private var settingsLoaded = false
|
private var settingsLoaded = false
|
||||||
private var loadedRecursiveIsoPathsValue = false
|
|
||||||
|
|
||||||
private val isGameSpecific: Boolean
|
private val isGameSpecific: Boolean
|
||||||
get() = !TextUtils.isEmpty(gameId)
|
get() = !TextUtils.isEmpty(gameId)
|
||||||
|
@ -41,8 +39,6 @@ class Settings : Closeable {
|
||||||
check(!NativeLibrary.IsRunning()) { "Attempted to load game INI while emulating" }
|
check(!NativeLibrary.IsRunning()) { "Attempted to load game INI while emulating" }
|
||||||
NativeConfig.loadGameInis(gameId, revision)
|
NativeConfig.loadGameInis(gameId, revision)
|
||||||
}
|
}
|
||||||
|
|
||||||
loadedRecursiveIsoPathsValue = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadSettings(gameId: String, revision: Int, isWii: Boolean) {
|
fun loadSettings(gameId: String, revision: Int, isWii: Boolean) {
|
||||||
|
@ -65,11 +61,6 @@ class Settings : Closeable {
|
||||||
|
|
||||||
NativeLibrary.ReloadLoggerConfig()
|
NativeLibrary.ReloadLoggerConfig()
|
||||||
NativeLibrary.UpdateGCAdapterScanThread()
|
NativeLibrary.UpdateGCAdapterScanThread()
|
||||||
|
|
||||||
if (loadedRecursiveIsoPathsValue != BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.boolean) {
|
|
||||||
// Refresh game library
|
|
||||||
GameFileCacheManager.startRescan()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// custom game settings
|
// custom game settings
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
|
|
|
@ -2,9 +2,14 @@
|
||||||
|
|
||||||
package org.dolphinemu.dolphinemu.services;
|
package org.dolphinemu.dolphinemu.services;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.ConfigChangedCallback;
|
||||||
import org.dolphinemu.dolphinemu.model.GameFile;
|
import org.dolphinemu.dolphinemu.model.GameFile;
|
||||||
import org.dolphinemu.dolphinemu.model.GameFileCache;
|
import org.dolphinemu.dolphinemu.model.GameFileCache;
|
||||||
import org.dolphinemu.dolphinemu.ui.platform.Platform;
|
import org.dolphinemu.dolphinemu.ui.platform.Platform;
|
||||||
|
@ -26,6 +31,7 @@ public final class GameFileCacheManager
|
||||||
new MutableLiveData<>(new GameFile[]{});
|
new MutableLiveData<>(new GameFile[]{});
|
||||||
private static boolean sFirstLoadDone = false;
|
private static boolean sFirstLoadDone = false;
|
||||||
private static boolean sRunRescanAfterLoad = false;
|
private static boolean sRunRescanAfterLoad = false;
|
||||||
|
private static boolean sRecursiveScanEnabled;
|
||||||
|
|
||||||
private static final ExecutorService sExecutor = Executors.newFixedThreadPool(1);
|
private static final ExecutorService sExecutor = Executors.newFixedThreadPool(1);
|
||||||
private static final MutableLiveData<Boolean> sLoadInProgress = new MutableLiveData<>(false);
|
private static final MutableLiveData<Boolean> sLoadInProgress = new MutableLiveData<>(false);
|
||||||
|
@ -182,6 +188,7 @@ public final class GameFileCacheManager
|
||||||
if (!sFirstLoadDone)
|
if (!sFirstLoadDone)
|
||||||
{
|
{
|
||||||
sFirstLoadDone = true;
|
sFirstLoadDone = true;
|
||||||
|
setUpAutomaticRescan();
|
||||||
sGameFileCache.load();
|
sGameFileCache.load();
|
||||||
if (sGameFileCache.getSize() != 0)
|
if (sGameFileCache.getSize() != 0)
|
||||||
{
|
{
|
||||||
|
@ -258,4 +265,19 @@ public final class GameFileCacheManager
|
||||||
sGameFileCache = new GameFileCache();
|
sGameFileCache = new GameFileCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setUpAutomaticRescan()
|
||||||
|
{
|
||||||
|
sRecursiveScanEnabled = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean();
|
||||||
|
new ConfigChangedCallback(() ->
|
||||||
|
new Handler(Looper.getMainLooper()).post(() ->
|
||||||
|
{
|
||||||
|
boolean recursiveScanEnabled = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean();
|
||||||
|
if (sRecursiveScanEnabled != recursiveScanEnabled)
|
||||||
|
{
|
||||||
|
sRecursiveScanEnabled = recursiveScanEnabled;
|
||||||
|
startRescan();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue