make completed objectives static

This commit is contained in:
Milos Kozak 2016-08-10 23:32:11 +02:00
parent d023e4ae32
commit a3e656dc6f
2 changed files with 8 additions and 11 deletions

View file

@ -379,11 +379,8 @@ public class DataService extends IntentService {
MainApp.bus().post(new EventNewBG()); MainApp.bus().post(new EventNewBG());
} }
// Objectives 0 // Objectives 0
ObjectivesPlugin objectivesPlugin = (ObjectivesPlugin) MainApp.getSpecificPlugin(ObjectivesPlugin.class); ObjectivesPlugin.bgIsAvailableInNS = true;
if (objectivesPlugin != null) { ObjectivesPlugin.saveProgress();
objectivesPlugin.bgIsAvailableInNS = true;
objectivesPlugin.saveProgress();
}
} }
if (intent.getAction().equals(Intents.ACTION_NEW_MBG)) { if (intent.getAction().equals(Intents.ACTION_NEW_MBG)) {

View file

@ -23,7 +23,7 @@ import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
public class ObjectivesPlugin implements PluginBase, ConstraintsInterface { public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
private static Logger log = LoggerFactory.getLogger(ObjectivesPlugin.class); private static Logger log = LoggerFactory.getLogger(ObjectivesPlugin.class);
public List<Objective> objectives; public static List<Objective> objectives;
boolean fragmentVisible = true; boolean fragmentVisible = true;
@ -92,11 +92,11 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
} }
// Objective 0 // Objective 0
public boolean bgIsAvailableInNS = false; public static boolean bgIsAvailableInNS = false;
public boolean pumpStatusIsAvailableInNS = false; public static boolean pumpStatusIsAvailableInNS = false;
// Objective 1 // Objective 1
public Integer manualEnacts = 0; public static Integer manualEnacts = 0;
public final Integer manualEnactsNeeded = 20; public static final Integer manualEnactsNeeded = 20;
public class RequirementResult { public class RequirementResult {
boolean done = false; boolean done = false;
@ -176,7 +176,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
new Date(0, 0, 0))); new Date(0, 0, 0)));
} }
public void saveProgress() { public static void saveProgress() {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
SharedPreferences.Editor editor = settings.edit(); SharedPreferences.Editor editor = settings.edit();
for (int num = 0; num < objectives.size(); num++) { for (int num = 0; num < objectives.size(); num++) {