diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java index 2dfaefe482..47dcbd4d96 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java @@ -57,7 +57,6 @@ public class VirtualPumpFragment extends SubscriberFragment { batteryView = (TextView) view.findViewById(R.id.virtualpump_battery); reservoirView = (TextView) view.findViewById(R.id.virtualpump_reservoir); - updateGUI(); return view; } @@ -66,6 +65,12 @@ public class VirtualPumpFragment extends SubscriberFragment { updateGUI(); } + @Override + public void onResume() { + super.onResume(); + updateGUI(); + } + @Override protected void updateGUI() { Activity activity = getActivity(); @@ -73,8 +78,8 @@ public class VirtualPumpFragment extends SubscriberFragment { activity.runOnUiThread(new Runnable() { @Override public void run() { - - basaBasalRateView.setText(VirtualPumpPlugin.getInstance().getBaseBasalRate() + "U"); + VirtualPumpPlugin virtualPump = VirtualPumpPlugin.getInstance(); + basaBasalRateView.setText(virtualPump.getBaseBasalRate() + "U"); if (MainApp.getConfigBuilder().isTempBasalInProgress()) { tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull()); } else { @@ -85,8 +90,8 @@ public class VirtualPumpFragment extends SubscriberFragment { } else { extendedBolusView.setText(""); } - batteryView.setText(VirtualPumpPlugin.getInstance().batteryPercent + "%"); - reservoirView.setText(VirtualPumpPlugin.getInstance().reservoirInUnits + "U"); + batteryView.setText(virtualPump.batteryPercent + "%"); + reservoirView.setText(virtualPump.reservoirInUnits + "U"); } }); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java index b42d1abfd6..6f7a077416 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java @@ -204,7 +204,11 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface { @Override public double getBaseBasalRate() { - return MainApp.getConfigBuilder().getProfile().getBasal(); + Profile profile = MainApp.getConfigBuilder().getProfile(); + if (profile != null) + return profile.getBasal(); + else + return 0d; } @Override