Start loading UI preferences as soon as possible
This commit is contained in:
parent
fd0dc88c64
commit
5da6034c76
@ -105,11 +105,15 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
timer.reset();
|
timer.reset();
|
||||||
|
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
final Languages languages = new Languages(this, preferences);
|
// start loading UI preferences as soon as possible in order for them to be loaded by the
|
||||||
|
// time they are queried
|
||||||
|
final SharedPreferences uiPrefs = AppModule.provideUiPreferences(this);
|
||||||
|
|
||||||
|
final Languages languages = new Languages(this, prefs);
|
||||||
timer.addSplit("languages");
|
timer.addSplit("languages");
|
||||||
|
|
||||||
onPreCreate(preferences, languages);
|
onPreCreate(prefs, uiPrefs, languages);
|
||||||
timer.addSplit("onPreCreate");
|
timer.addSplit("onPreCreate");
|
||||||
|
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
@ -118,7 +122,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
initDagger(languages);
|
initDagger(languages);
|
||||||
timer.addSplit("initDagger");
|
timer.addSplit("initDagger");
|
||||||
|
|
||||||
onPostCreate(preferences, languages);
|
onPostCreate(prefs, languages);
|
||||||
timer.addSplit("onPostCreate");
|
timer.addSplit("onPostCreate");
|
||||||
timer.dumpToLog();
|
timer.dumpToLog();
|
||||||
}
|
}
|
||||||
@ -132,11 +136,11 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
history.init(initThread);
|
history.init(initThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPostCreate(@Nonnull final SharedPreferences preferences, @Nonnull Languages languages) {
|
private void onPostCreate(@Nonnull final SharedPreferences prefs, @Nonnull Languages languages) {
|
||||||
App.init(this);
|
App.init(this);
|
||||||
languages.init();
|
languages.init();
|
||||||
|
|
||||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
languages.updateContextLocale(this, true);
|
languages.updateContextLocale(this, true);
|
||||||
|
|
||||||
calculator.init(initThread);
|
calculator.init(initThread);
|
||||||
@ -147,7 +151,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
warmUpEngine();
|
warmUpEngine();
|
||||||
// delayed GA reporting in order to avoid initialization of GA on the main
|
// delayed GA reporting in order to avoid initialization of GA on the main
|
||||||
// application thread and to postpone it as much as possible
|
// application thread and to postpone it as much as possible
|
||||||
ga.get().reportInitially(preferences);
|
ga.get().reportInitially(prefs);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -163,7 +167,8 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPreCreate(@Nonnull SharedPreferences preferences, @Nonnull Languages languages) {
|
private void onPreCreate(@Nonnull SharedPreferences prefs, @NonNull SharedPreferences uiPrefs,
|
||||||
|
@Nonnull Languages languages) {
|
||||||
// first we need to setup crash handler and memory leak analyzer
|
// first we need to setup crash handler and memory leak analyzer
|
||||||
if (AcraErrorReporter.ENABLED) {
|
if (AcraErrorReporter.ENABLED) {
|
||||||
ACRA.init(this, new ACRAConfiguration()
|
ACRA.init(this, new ACRAConfiguration()
|
||||||
@ -175,11 +180,11 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
}
|
}
|
||||||
|
|
||||||
// then we should set default preferences
|
// then we should set default preferences
|
||||||
Preferences.init(this, preferences);
|
Preferences.init(this, prefs);
|
||||||
UiPreferences.init(preferences, AppModule.provideUiPreferences(this));
|
UiPreferences.init(prefs, uiPrefs);
|
||||||
|
|
||||||
// and change application's theme/language is needed
|
// and change application's theme/language is needed
|
||||||
final Preferences.Gui.Theme theme = Preferences.Gui.getTheme(preferences);
|
final Preferences.Gui.Theme theme = Preferences.Gui.getTheme(prefs);
|
||||||
setTheme(theme.theme);
|
setTheme(theme.theme);
|
||||||
|
|
||||||
final Language language = languages.getCurrent();
|
final Language language = languages.getCurrent();
|
||||||
|
Loading…
Reference in New Issue
Block a user