Reuse prefs object

This commit is contained in:
Sergey Solovyev 2017-05-26 19:02:41 +02:00
parent 5da6034c76
commit a8821e75bf
2 changed files with 6 additions and 7 deletions

View File

@ -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

View File

@ -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);