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();