Languages should start listening to preferences changes only after default values have been set

This commit is contained in:
serso 2016-01-10 12:40:21 +01:00
parent 666c3730bc
commit 4a7f44b864
2 changed files with 8 additions and 1 deletions

View File

@ -161,6 +161,7 @@ public final class App {
App.broadcaster = new CalculatorBroadcaster(application, preferences, bus); App.broadcaster = new CalculatorBroadcaster(application, preferences, bus);
App.screenMetrics = new ScreenMetrics(application); App.screenMetrics = new ScreenMetrics(application);
App.languages = languages; App.languages = languages;
App.languages.init();
App.wizards = new CalculatorWizards(application); App.wizards = new CalculatorWizards(application);
App.initialized = true; App.initialized = true;

View File

@ -30,7 +30,6 @@ public final class Languages implements SharedPreferences.OnSharedPreferenceChan
public Languages(@Nonnull SharedPreferences preferences) { public Languages(@Nonnull SharedPreferences preferences) {
this.preferences = preferences; this.preferences = preferences;
this.preferences.registerOnSharedPreferenceChangeListener(this);
} }
@Nullable @Nullable
@ -68,6 +67,13 @@ public final class Languages implements SharedPreferences.OnSharedPreferenceChan
return null; return null;
} }
/**
* This method should be called only when default values have been set to application's preferences
*/
public void init() {
preferences.registerOnSharedPreferenceChangeListener(this);
}
@Nonnull @Nonnull
public List<Language> getList() { public List<Language> getList() {
Check.isMainThread(); Check.isMainThread();