From a8821e75bf849cb4873216e12efe01bc62ac59dc Mon Sep 17 00:00:00 2001 From: Sergey Solovyev Date: Fri, 26 May 2017 19:02:41 +0200 Subject: [PATCH] Reuse prefs object --- .../java/org/solovyev/android/calculator/App.java | 11 +++++------ .../android/calculator/CalculatorApplication.java | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) 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 e96770ce..9fed051d 100644 --- a/app/src/main/java/org/solovyev/android/calculator/App.java +++ b/app/src/main/java/org/solovyev/android/calculator/App.java @@ -22,9 +22,6 @@ package org.solovyev.android.calculator; -import org.solovyev.android.Check; -import org.solovyev.android.calculator.floating.FloatingCalculatorService; - import android.app.Activity; import android.app.Application; import android.app.Dialog; @@ -39,7 +36,6 @@ import android.net.Uri; import android.os.Build; import android.os.IBinder; import android.os.Looper; -import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; @@ -57,6 +53,9 @@ import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.widget.ArrayAdapter; +import org.solovyev.android.Check; +import org.solovyev.android.calculator.floating.FloatingCalculatorService; + import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -75,9 +74,9 @@ public final class App { throw new AssertionError(); } - public static void init(@Nonnull CalculatorApplication application) { + public static void init(@Nonnull CalculatorApplication application, @NonNull SharedPreferences prefs) { App.application = application; - App.preferences = PreferenceManager.getDefaultSharedPreferences(application); + App.preferences = prefs; } @Nonnull diff --git a/app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java b/app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java index fe4d67f8..93d692db 100644 --- a/app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java +++ b/app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java @@ -137,7 +137,7 @@ public class CalculatorApplication extends android.app.Application implements Sh } private void onPostCreate(@Nonnull final SharedPreferences prefs, @Nonnull Languages languages) { - App.init(this); + App.init(this, prefs); languages.init(); prefs.registerOnSharedPreferenceChangeListener(this);