proper iob update on treatmnets&temps tab

This commit is contained in:
Milos Kozak 2016-06-24 23:27:52 +02:00
parent 35ff53dbb4
commit 582ffc3c9a
2 changed files with 7 additions and 25 deletions

View file

@ -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));
}
});
}

View file

@ -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));
}
});
}