From 4a7f44b864e22320e5d672eaf2b13fc36c26edcb Mon Sep 17 00:00:00 2001 From: serso Date: Sun, 10 Jan 2016 12:40:21 +0100 Subject: [PATCH] Languages should start listening to preferences changes only after default values have been set --- .../main/java/org/solovyev/android/calculator/App.java | 1 + .../solovyev/android/calculator/language/Languages.java | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/solovyev/android/calculator/App.java b/app/src/main/java/org/solovyev/android/calculator/App.java index f58e8bd5..a9aa629e 100644 --- a/app/src/main/java/org/solovyev/android/calculator/App.java +++ b/app/src/main/java/org/solovyev/android/calculator/App.java @@ -161,6 +161,7 @@ public final class App { App.broadcaster = new CalculatorBroadcaster(application, preferences, bus); App.screenMetrics = new ScreenMetrics(application); App.languages = languages; + App.languages.init(); App.wizards = new CalculatorWizards(application); App.initialized = true; diff --git a/app/src/main/java/org/solovyev/android/calculator/language/Languages.java b/app/src/main/java/org/solovyev/android/calculator/language/Languages.java index fbf85730..06157df2 100644 --- a/app/src/main/java/org/solovyev/android/calculator/language/Languages.java +++ b/app/src/main/java/org/solovyev/android/calculator/language/Languages.java @@ -30,7 +30,6 @@ public final class Languages implements SharedPreferences.OnSharedPreferenceChan public Languages(@Nonnull SharedPreferences preferences) { this.preferences = preferences; - this.preferences.registerOnSharedPreferenceChangeListener(this); } @Nullable @@ -68,6 +67,13 @@ public final class Languages implements SharedPreferences.OnSharedPreferenceChan 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 public List getList() { Check.isMainThread();