From 582ffc3c9a4329d7dcfc3f6f07756aef96e3e4a0 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 24 Jun 2016 23:27:52 +0200 Subject: [PATCH] proper iob update on treatmnets&temps tab --- .../plugins/TempBasals/TempBasalsFragment.java | 14 +++----------- .../plugins/Treatments/TreatmentsFragment.java | 18 ++++-------------- 2 files changed, 7 insertions(+), 25 deletions(-) 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 d7f5674e7d..7f2e28c1aa 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 @@ -207,17 +207,6 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa TempBasal t = tempBasals.get(pos); total.plus(t.iobCalc(now)); } - final IobTotal finalTotal = total; - - Activity activity = getActivity(); - if (visibleNow && activity != null && recyclerView != null) - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (iobTotal != null) - iobTotal.setText(formatNumber2decimalplaces.format(finalTotal.basaliob)); - } - }); lastCalculationTimestamp = new Date().getTime(); lastCalculation = total; @@ -385,6 +374,9 @@ 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)); + } }); } 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 e83b3aee8c..f81cb17f22 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 @@ -154,20 +154,6 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener total.bolussnooze += bIOB.iobContrib; } - final IobTotal finalTotal = total; - - Activity activity = getActivity(); - if (visibleNow && activity != null && recyclerView != null) - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (iobTotal != null) - iobTotal.setText(formatNumber2decimalplaces.format(finalTotal.iob)); - if (activityTotal != null) - activityTotal.setText(formatNumber3decimalplaces.format(finalTotal.activity)); - } - }); - lastCalculationTimestamp = new Date().getTime(); lastCalculation = total; } @@ -346,6 +332,10 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener @Override public void run() { recyclerView.swapAdapter(new RecyclerViewAdapter(treatments), false); + if (lastCalculation != null) + iobTotal.setText(formatNumber2decimalplaces.format(lastCalculation.iob)); + if (lastCalculation != null) + activityTotal.setText(formatNumber3decimalplaces.format(lastCalculation.activity)); } }); }