fix virtual pump crash

This commit is contained in:
Milos Kozak 2017-08-01 17:53:28 +02:00
parent a24cbfda50
commit d2a5939ce3
2 changed files with 15 additions and 6 deletions

View file

@ -57,7 +57,6 @@ public class VirtualPumpFragment extends SubscriberFragment {
batteryView = (TextView) view.findViewById(R.id.virtualpump_battery); batteryView = (TextView) view.findViewById(R.id.virtualpump_battery);
reservoirView = (TextView) view.findViewById(R.id.virtualpump_reservoir); reservoirView = (TextView) view.findViewById(R.id.virtualpump_reservoir);
updateGUI();
return view; return view;
} }
@ -66,6 +65,12 @@ public class VirtualPumpFragment extends SubscriberFragment {
updateGUI(); updateGUI();
} }
@Override
public void onResume() {
super.onResume();
updateGUI();
}
@Override @Override
protected void updateGUI() { protected void updateGUI() {
Activity activity = getActivity(); Activity activity = getActivity();
@ -73,8 +78,8 @@ public class VirtualPumpFragment extends SubscriberFragment {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
VirtualPumpPlugin virtualPump = VirtualPumpPlugin.getInstance();
basaBasalRateView.setText(VirtualPumpPlugin.getInstance().getBaseBasalRate() + "U"); basaBasalRateView.setText(virtualPump.getBaseBasalRate() + "U");
if (MainApp.getConfigBuilder().isTempBasalInProgress()) { if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull()); tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
} else { } else {
@ -85,8 +90,8 @@ public class VirtualPumpFragment extends SubscriberFragment {
} else { } else {
extendedBolusView.setText(""); extendedBolusView.setText("");
} }
batteryView.setText(VirtualPumpPlugin.getInstance().batteryPercent + "%"); batteryView.setText(virtualPump.batteryPercent + "%");
reservoirView.setText(VirtualPumpPlugin.getInstance().reservoirInUnits + "U"); reservoirView.setText(virtualPump.reservoirInUnits + "U");
} }
}); });
} }

View file

@ -204,7 +204,11 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override @Override
public double getBaseBasalRate() { public double getBaseBasalRate() {
return MainApp.getConfigBuilder().getProfile().getBasal(); Profile profile = MainApp.getConfigBuilder().getProfile();
if (profile != null)
return profile.getBasal();
else
return 0d;
} }
@Override @Override