From 4f3b5f551a6389edd24cc22555d4de0a22ccae21 Mon Sep 17 00:00:00 2001 From: Susan Date: Fri, 18 Aug 2017 20:58:54 +0200 Subject: [PATCH] moved the code of the bg update to the top before all the loop logic happens, so there would be no delay --- .../plugins/Overview/OverviewFragment.java | 55 +++++++++++-------- 1 file changed, 31 insertions(+), 24 deletions(-) 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 342f6bd20f..ef916429fe 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 @@ -912,6 +912,34 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, return; } + Double lowLine = SP.getDouble("low_mark", 0d); + Double highLine = SP.getDouble("high_mark", 0d); + + //Start with updating the BG as it is unaffected by loop. + // **** BG value **** + if (lastBG != null) { + int color = MainApp.sResources.getColor(R.color.inrange); + if (lastBG.valueToUnits(units) < lowLine) + color = MainApp.sResources.getColor(R.color.low); + else if (lastBG.valueToUnits(units) > highLine) + color = MainApp.sResources.getColor(R.color.high); + bgView.setText(lastBG.valueToUnitsToString(units)); + arrowView.setText(lastBG.directionToSymbol()); + bgView.setTextColor(color); + arrowView.setTextColor(color); + GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(); + if (glucoseStatus != null) { + deltaView.setText("Δ " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units); + if (avgdeltaView != null) + avgdeltaView.setText("øΔ15m: " + Profile.toUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units) + + " øΔ40m: " + Profile.toUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units)); + } else { + deltaView.setText("Δ " + MainApp.sResources.getString(R.string.notavailable)); + if (avgdeltaView != null) + avgdeltaView.setText(""); + } + } + // open loop mode final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun; if (Config.APS && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable) { @@ -1105,8 +1133,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, treatmentButton.setVisibility(View.GONE); } - Double lowLine = SP.getDouble("low_mark", 0d); - Double highLine = SP.getDouble("high_mark", 0d); + if (lowLine < 1) { lowLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units); } @@ -1115,28 +1142,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } // **** BG value **** - if (lastBG != null) { - int color = MainApp.sResources.getColor(R.color.inrange); - if (lastBG.valueToUnits(units) < lowLine) - color = MainApp.sResources.getColor(R.color.low); - else if (lastBG.valueToUnits(units) > highLine) - color = MainApp.sResources.getColor(R.color.high); - bgView.setText(lastBG.valueToUnitsToString(units)); - arrowView.setText(lastBG.directionToSymbol()); - bgView.setTextColor(color); - arrowView.setTextColor(color); - GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(); - if (glucoseStatus != null) { - deltaView.setText("Δ " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units); - if (avgdeltaView != null) - avgdeltaView.setText("øΔ15m: " + Profile.toUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units) + - " øΔ40m: " + Profile.toUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units)); - } else { - deltaView.setText("Δ " + MainApp.sResources.getString(R.string.notavailable)); - if (avgdeltaView != null) - avgdeltaView.setText(""); - } - } else { + if (lastBG == null) { //left this here as it seems you want to exit at this point if it is null... + return; } Integer flag = bgView.getPaintFlags();