From 37844545e770dea10bca0ce23516615ef640a8ad Mon Sep 17 00:00:00 2001 From: simonpoole Date: Sat, 14 Dec 2024 08:40:24 +0100 Subject: [PATCH] Fix some minor code smells and let auto save run the whole time --- src/main/java/de/blau/android/App.java | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/blau/android/App.java b/src/main/java/de/blau/android/App.java index d818e67e0..88cd4b1be 100644 --- a/src/main/java/de/blau/android/App.java +++ b/src/main/java/de/blau/android/App.java @@ -207,7 +207,13 @@ public class App extends Application implements android.app.Application.Activity protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); + setupFST(); + } + /** + * Setup the FST singleton + */ + private static void setupFST() { singletonConf = FSTConfiguration.createAndroidDefaultConfiguration(); singletonConf.registerSerializer(TreeMap.class, new FSTMapSerializer(), true); } @@ -217,10 +223,7 @@ public void onCreate() { ACRA.init(this); super.onCreate(); registerActivityLifecycleCallbacks(this); - String appName = getString(R.string.app_name); - String appVersion = getString(R.string.app_version); - userAgent = appName + "/" + appVersion; - currentInstance = this; + setupMisc(this); setConfiguration(getResources().getConfiguration()); // register a broadcast receiver for DeX mode // this will remain registered as long as the @@ -234,6 +237,16 @@ public void onCreate() { } } + /** + * Setup misc singletons + */ + private static void setupMisc(@NonNull App app) { + String appName = app.getString(R.string.app_name); + String appVersion = app.getString(R.string.app_version); + userAgent = appName + "/" + appVersion; + currentInstance = app; + } + /** * Retrieve the saved Configuration object * @@ -902,11 +915,6 @@ public void onActivityDestroyed(Activity activity) { synchronized (this) { propertyEditorRunning = false; } - return; - } - if (activity instanceof Main && autosaveFuture != null) { - Log.i(DEBUG_TAG, "Cancelling autosave"); - autosaveFuture.cancel(false); } }