Skip to content

Commit

Permalink
Fix some minor code smells and let auto save run the whole time
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpoole committed Dec 14, 2024
1 parent aa3819b commit 3784454
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/main/java/de/blau/android/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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
Expand All @@ -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
*
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 3784454

Please sign in to comment.