check for null

This commit is contained in:
Milos Kozak 2017-04-14 16:10:20 +02:00
parent 7aa2aa4d24
commit 781aa6e657

View file

@ -259,40 +259,42 @@ public class OverviewFragment extends Fragment {
acceptTempButton.setOnClickListener(new View.OnClickListener() { acceptTempButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false); if (ConfigBuilderPlugin.getActiveLoop() != null) {
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun; ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false);
if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.changeRequested) { final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.changeRequested) {
builder.setTitle(getContext().getString(R.string.confirmation)); AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setMessage(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed); builder.setTitle(getContext().getString(R.string.confirmation));
builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() { builder.setMessage(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
public void onClick(DialogInterface dialog, int id) { builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
sHandler.post(new Runnable() { public void onClick(DialogInterface dialog, int id) {
@Override sHandler.post(new Runnable() {
public void run() { @Override
hideTempRecommendation(); public void run() {
PumpEnactResult applyResult = MainApp.getConfigBuilder().applyAPSRequest(finalLastRun.constraintsProcessed); hideTempRecommendation();
if (applyResult.enacted) { PumpEnactResult applyResult = MainApp.getConfigBuilder().applyAPSRequest(finalLastRun.constraintsProcessed);
finalLastRun.setByPump = applyResult; if (applyResult.enacted) {
finalLastRun.lastEnact = new Date(); finalLastRun.setByPump = applyResult;
finalLastRun.lastOpenModeAccept = new Date(); finalLastRun.lastEnact = new Date();
MainApp.getConfigBuilder().uploadDeviceStatus(); finalLastRun.lastOpenModeAccept = new Date();
ObjectivesPlugin objectivesPlugin = (ObjectivesPlugin) MainApp.getSpecificPlugin(ObjectivesPlugin.class); MainApp.getConfigBuilder().uploadDeviceStatus();
if (objectivesPlugin != null) { ObjectivesPlugin objectivesPlugin = (ObjectivesPlugin) MainApp.getSpecificPlugin(ObjectivesPlugin.class);
objectivesPlugin.manualEnacts++; if (objectivesPlugin != null) {
objectivesPlugin.saveProgress(); objectivesPlugin.manualEnacts++;
objectivesPlugin.saveProgress();
}
} }
updateGUIIfVisible();
} }
updateGUIIfVisible(); });
} Answers.getInstance().logCustom(new CustomEvent("AcceptTemp"));
}); }
Answers.getInstance().logCustom(new CustomEvent("AcceptTemp")); });
} builder.setNegativeButton(getContext().getString(R.string.cancel), null);
}); builder.show();
builder.setNegativeButton(getContext().getString(R.string.cancel), null); }
builder.show(); updateGUI();
} }
updateGUI();
} }
}); });