From 878e3e092188a7a221e01d62006ba61264d5a8f2 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 10 May 2017 21:37:34 +0200 Subject: [PATCH] use SP --- .../plugins/TempBasals/TempBasalsPlugin.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsPlugin.java index 51c5a2c0a1..cbc018278a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsPlugin.java @@ -1,7 +1,5 @@ package info.nightscout.androidaps.plugins.TempBasals; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; import android.support.annotation.Nullable; import com.j256.ormlite.dao.Dao; @@ -20,12 +18,13 @@ import java.util.List; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.db.TempBasal; import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventTempBasalChange; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.TempBasalsInterface; -import info.nightscout.androidaps.data.IobTotal; +import info.nightscout.utils.SP; /** * Created by mike on 05.08.2016. @@ -45,8 +44,7 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface { private static boolean fragmentVisible = true; public TempBasalsPlugin() { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); - useExtendedBoluses = sharedPreferences.getBoolean("danar_useextended", false); + useExtendedBoluses = SP.getBoolean("danar_useextended", false); initializeData(); MainApp.bus().register(this); } @@ -271,9 +269,10 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface { } public void onStatusEvent(final EventPreferenceChange s) { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); - useExtendedBoluses = sharedPreferences.getBoolean("danar_useextended", false); - initializeData(); + if (s.isChanged("danar_useextended")) { + useExtendedBoluses = SP.getBoolean("danar_useextended", false); + initializeData(); + } }