Simplify show-targets view logic

This commit is contained in:
AdrianLxM 2020-05-20 22:34:09 +02:00
parent bf412ea798
commit 06e97400f7

View file

@ -655,13 +655,11 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning)) overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
overview_temptarget?.text = Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end(), resourceHelper) overview_temptarget?.text = Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end(), resourceHelper)
} else { } else {
//If the target is not the same as set in the profile then oref has overridden it // If the target is not the same as set in the profile then oref has overridden it
//show this change to the user if it exists val targetUsed = lastRun?.constraintsProcessed?.targetBG ?: 0.0
var targetused = lastRun?.constraintsProcessed?.targetBG
if (targetused != null && targetused != 0.0) {
if (((profile.targetLowMgdl+profile.targetHighMgdl)/2)!= targetused) { if (targetUsed != 0.0 && profile.targetMgdl != targetUsed) {
overview_temptarget?.text = Profile.toTargetRangeString(targetused, targetused, Constants.MGDL, units) overview_temptarget?.text = Profile.toTargetRangeString(targetUsed, targetUsed, Constants.MGDL, units)
overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.tempTargetBackground)) overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.tempTargetBackground))
} else { } else {
@ -669,11 +667,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault))
overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units) overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units)
} }
} else {
overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault))
overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault))
overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units)
}
} }
// Basal, TBR // Basal, TBR