diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResult.java index 0d984f8f9f..5016280479 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResult.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResult.java @@ -20,28 +20,34 @@ public class DetermineBasalResult extends APSResult { public DetermineBasalResult(V8Object result, JSONObject j) { json = j; - reason = result.getString("reason"); - eventualBG = result.getDouble("eventualBG"); - snoozeBG = result.getDouble("snoozeBG"); - if (result.contains("rate")) { - rate = result.getDouble("rate"); - if (rate < 0d) rate = 0d; - changeRequested = true; - } else { + if (result.contains("error")) { + reason = result.getString("error"); + changeRequested = false; rate = -1; - changeRequested = false; - } - if (result.contains("duration")) { - duration = result.getInteger("duration"); - changeRequested = changeRequested; - } else { duration = -1; - changeRequested = false; + mealAssist = ""; + } else { + eventualBG = result.getDouble("eventualBG"); + snoozeBG = result.getDouble("snoozeBG"); + if (result.contains("rate")) { + rate = result.getDouble("rate"); + if (rate < 0d) rate = 0d; + changeRequested = true; + } else { + rate = -1; + changeRequested = false; + } + if (result.contains("duration")) { + duration = result.getInteger("duration"); + changeRequested = changeRequested; + } else { + duration = -1; + changeRequested = false; + } + if (result.contains("mealAssist")) { + mealAssist = result.getString("mealAssist"); + } else mealAssist = ""; } - if (result.contains("mealAssist")) { - mealAssist = result.getString("mealAssist"); - } else mealAssist = ""; - result.release(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/IobTotal.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/IobTotal.java index 7cb640e377..5f03c845ad 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/IobTotal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/IobTotal.java @@ -30,11 +30,11 @@ public class IobTotal { public IobTotal plus(IobTotal other) { iob += other.iob; - activity = other.activity; - bolussnooze = other.bolussnooze; - basaliob = other.iob; - netbasalinsulin = other.netbasalinsulin; - hightempinsulin = other.hightempinsulin; + activity += other.activity; + bolussnooze += other.bolussnooze; + basaliob += other.basaliob; + netbasalinsulin += other.netbasalinsulin; + hightempinsulin += other.hightempinsulin; netInsulin += other.netInsulin; netRatio += other.netRatio; return this; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 71784b6afb..0db413d72b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -341,7 +341,9 @@ public class OverviewFragment extends Fragment implements PluginBase { if (basalIob == null) basalIob = new IobTotal(); IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round(); - String iobtext = getString(R.string.treatments_iob_label_string) + " " + formatNumber2decimalplaces.format(iobTotal.iob) + "U (" + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(bolusIob.iob) + "U " + getString(R.string.basal) + ": " + formatNumber2decimalplaces.format(basalIob.iob) + "U)"; + String iobtext = getString(R.string.treatments_iob_label_string) + " " + formatNumber2decimalplaces.format(iobTotal.iob) + "U (" + + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(bolusIob.iob) + "U " + + getString(R.string.basal) + ": " + formatNumber2decimalplaces.format(basalIob.basaliob) + "U)"; iobView.setText(iobtext); // ****** GRAPH ******* diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsFragment.java index 7f2e28c1aa..adf342f71e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsFragment.java @@ -44,7 +44,7 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa RecyclerView recyclerView; LinearLayoutManager llm; - TextView iobTotal; + TextView tempBasalTotalView; public long lastCalculationTimestamp = 0; public IobTotal lastCalculation; @@ -205,7 +205,8 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa IobTotal total = new IobTotal(); for (Integer pos = 0; pos < tempBasals.size(); pos++) { TempBasal t = tempBasals.get(pos); - total.plus(t.iobCalc(now)); + IobTotal calc = t.iobCalc(now); + total.plus(calc); } lastCalculationTimestamp = new Date().getTime(); @@ -348,8 +349,8 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa RecyclerViewAdapter adapter = new RecyclerViewAdapter(tempBasals); recyclerView.setAdapter(adapter); - iobTotal = (TextView) view.findViewById(R.id.tempbasals_iobtotal); - + tempBasalTotalView = (TextView) view.findViewById(R.id.tempbasals_totaltempiob); + updateGUI(); return view; } @@ -374,9 +375,10 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa @Override public void run() { recyclerView.swapAdapter(new RecyclerViewAdapter(tempBasals), false); - if (lastCalculation != null) - iobTotal.setText(formatNumber2decimalplaces.format(lastCalculation.basaliob)); - + if (lastCalculation != null) { + String totalText = formatNumber2decimalplaces.format(lastCalculation.basaliob) + "U"; + tempBasalTotalView.setText(totalText); + } } }); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java index f81cb17f22..d9b09ce64e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java @@ -284,6 +284,7 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener refreshFromNS = (Button) view.findViewById(R.id.treatments_reshreshfromnightscout); refreshFromNS.setOnClickListener(this); + updateGUI(); return view; } diff --git a/app/src/main/res/layout/tempbasals_fragment.xml b/app/src/main/res/layout/tempbasals_fragment.xml index 8486bfbf32..b3925192cd 100644 --- a/app/src/main/res/layout/tempbasals_fragment.xml +++ b/app/src/main/res/layout/tempbasals_fragment.xml @@ -28,7 +28,7 @@