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());
}
// Objectives 0
ObjectivesPlugin objectivesPlugin = (ObjectivesPlugin) MainApp.getSpecificPlugin(ObjectivesPlugin.class);
if (objectivesPlugin != null) {
objectivesPlugin.bgIsAvailableInNS = true;
objectivesPlugin.saveProgress();
}
ObjectivesPlugin.bgIsAvailableInNS = true;
ObjectivesPlugin.saveProgress();
}
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 {
private static Logger log = LoggerFactory.getLogger(ObjectivesPlugin.class);
public List<Objective> objectives;
public static List<Objective> objectives;
boolean fragmentVisible = true;
@ -92,11 +92,11 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
}
// Objective 0
public boolean bgIsAvailableInNS = false;
public boolean pumpStatusIsAvailableInNS = false;
public static boolean bgIsAvailableInNS = false;
public static boolean pumpStatusIsAvailableInNS = false;
// Objective 1
public Integer manualEnacts = 0;
public final Integer manualEnactsNeeded = 20;
public static Integer manualEnacts = 0;
public static final Integer manualEnactsNeeded = 20;
public class RequirementResult {
boolean done = false;
@ -176,7 +176,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
new Date(0, 0, 0)));
}
public void saveProgress() {
public static void saveProgress() {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
SharedPreferences.Editor editor = settings.edit();
for (int num = 0; num < objectives.size(); num++) {