do not cache TBE and EB for displaying
This commit is contained in:
parent
8f3f9a7a65
commit
5d3035c09c
3 changed files with 17 additions and 37 deletions
|
@ -76,8 +76,6 @@ class OverviewData @Inject constructor(
|
||||||
pumpStatus = ""
|
pumpStatus = ""
|
||||||
calcProgress = ""
|
calcProgress = ""
|
||||||
lastBg = null
|
lastBg = null
|
||||||
temporaryBasal = null
|
|
||||||
extendedBolus = null
|
|
||||||
bolusIob = null
|
bolusIob = null
|
||||||
basalIob = null
|
basalIob = null
|
||||||
cobInfo = null
|
cobInfo = null
|
||||||
|
@ -161,11 +159,10 @@ class OverviewData @Inject constructor(
|
||||||
* TEMPORARY BASAL
|
* TEMPORARY BASAL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var temporaryBasal: TemporaryBasal? = null
|
|
||||||
|
|
||||||
val temporaryBasalText: String
|
val temporaryBasalText: String
|
||||||
get() =
|
get() =
|
||||||
profileFunction.getProfile()?.let { profile ->
|
profileFunction.getProfile()?.let { profile ->
|
||||||
|
var temporaryBasal = iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())
|
||||||
if (temporaryBasal?.isInProgress == false) temporaryBasal = null
|
if (temporaryBasal?.isInProgress == false) temporaryBasal = null
|
||||||
temporaryBasal?.let { "T:" + it.toStringShort() }
|
temporaryBasal?.let { "T:" + it.toStringShort() }
|
||||||
?: rh.gs(R.string.pump_basebasalrate, profile.getBasal())
|
?: rh.gs(R.string.pump_basebasalrate, profile.getBasal())
|
||||||
|
@ -173,7 +170,7 @@ class OverviewData @Inject constructor(
|
||||||
|
|
||||||
val temporaryBasalDialogText: String
|
val temporaryBasalDialogText: String
|
||||||
get() = profileFunction.getProfile()?.let { profile ->
|
get() = profileFunction.getProfile()?.let { profile ->
|
||||||
temporaryBasal?.let { temporaryBasal ->
|
iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())?.let { temporaryBasal ->
|
||||||
"${rh.gs(R.string.basebasalrate_label)}: ${rh.gs(R.string.pump_basebasalrate, profile.getBasal())}" +
|
"${rh.gs(R.string.basebasalrate_label)}: ${rh.gs(R.string.pump_basebasalrate, profile.getBasal())}" +
|
||||||
"\n" + rh.gs(R.string.tempbasal_label) + ": " + temporaryBasal.toStringFull(profile, dateUtil)
|
"\n" + rh.gs(R.string.tempbasal_label) + ": " + temporaryBasal.toStringFull(profile, dateUtil)
|
||||||
}
|
}
|
||||||
|
@ -183,7 +180,7 @@ class OverviewData @Inject constructor(
|
||||||
val temporaryBasalIcon: Int
|
val temporaryBasalIcon: Int
|
||||||
get() =
|
get() =
|
||||||
profileFunction.getProfile()?.let { profile ->
|
profileFunction.getProfile()?.let { profile ->
|
||||||
temporaryBasal?.let { temporaryBasal ->
|
iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())?.let { temporaryBasal ->
|
||||||
val percentRate = temporaryBasal.convertedToPercent(dateUtil.now(), profile)
|
val percentRate = temporaryBasal.convertedToPercent(dateUtil.now(), profile)
|
||||||
when {
|
when {
|
||||||
percentRate > 100 -> R.drawable.ic_cp_basal_tbr_high
|
percentRate > 100 -> R.drawable.ic_cp_basal_tbr_high
|
||||||
|
@ -194,27 +191,23 @@ class OverviewData @Inject constructor(
|
||||||
} ?: R.drawable.ic_cp_basal_no_tbr
|
} ?: R.drawable.ic_cp_basal_no_tbr
|
||||||
|
|
||||||
val temporaryBasalColor: Int
|
val temporaryBasalColor: Int
|
||||||
get() = temporaryBasal?.let { rh.gc(R.color.basal) }
|
get() = iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())?.let { rh.gc(R.color.basal) }
|
||||||
?: rh.gc(R.color.defaulttextcolor)
|
?: rh.gc(R.color.defaulttextcolor)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* EXTENDED BOLUS
|
* EXTENDED BOLUS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var extendedBolus: ExtendedBolus? = null
|
|
||||||
|
|
||||||
val extendedBolusText: String
|
val extendedBolusText: String
|
||||||
get() =
|
get() =
|
||||||
extendedBolus?.let { extendedBolus ->
|
iobCobCalculator.getExtendedBolus(dateUtil.now())?.let { extendedBolus ->
|
||||||
if (!extendedBolus.isInProgress(dateUtil)) {
|
if (!extendedBolus.isInProgress(dateUtil)) ""
|
||||||
this@OverviewData.extendedBolus = null
|
else if (!activePlugin.activePump.isFakingTempsByExtendedBoluses) rh.gs(R.string.pump_basebasalrate, extendedBolus.rate)
|
||||||
""
|
|
||||||
} else if (!activePlugin.activePump.isFakingTempsByExtendedBoluses) rh.gs(R.string.pump_basebasalrate, extendedBolus.rate)
|
|
||||||
else ""
|
else ""
|
||||||
} ?: ""
|
} ?: ""
|
||||||
|
|
||||||
val extendedBolusDialogText: String
|
val extendedBolusDialogText: String
|
||||||
get() = extendedBolus?.toStringFull(dateUtil) ?: ""
|
get() = iobCobCalculator.getExtendedBolus(dateUtil.now())?.toStringFull(dateUtil) ?: ""
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IOB, COB
|
* IOB, COB
|
||||||
|
@ -555,7 +548,14 @@ class OverviewData @Inject constructor(
|
||||||
|
|
||||||
// OfflineEvent
|
// OfflineEvent
|
||||||
repository.getOfflineEventDataFromTimeToTime(fromTime, endTime, true).blockingGet()
|
repository.getOfflineEventDataFromTimeToTime(fromTime, endTime, true).blockingGet()
|
||||||
.map { TherapyEventDataPoint(TherapyEvent(timestamp = it.timestamp, duration = it.duration, type = TherapyEvent.Type.APS_OFFLINE, glucoseUnit = TherapyEvent.GlucoseUnit.MMOL), rh, profileFunction, translator) }
|
.map {
|
||||||
|
TherapyEventDataPoint(
|
||||||
|
TherapyEvent(timestamp = it.timestamp, duration = it.duration, type = TherapyEvent.Type.APS_OFFLINE, glucoseUnit = TherapyEvent.GlucoseUnit.MMOL),
|
||||||
|
rh,
|
||||||
|
profileFunction,
|
||||||
|
translator
|
||||||
|
)
|
||||||
|
}
|
||||||
.forEach(filteredTreatments::add)
|
.forEach(filteredTreatments::add)
|
||||||
|
|
||||||
// Extended bolus
|
// Extended bolus
|
||||||
|
|
|
@ -722,7 +722,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
binding.infoLayout.extendedLayout.setOnClickListener {
|
binding.infoLayout.extendedLayout.setOnClickListener {
|
||||||
activity?.let { OKDialog.show(it, rh.gs(R.string.extended_bolus), overviewData.extendedBolusDialogText) }
|
activity?.let { OKDialog.show(it, rh.gs(R.string.extended_bolus), overviewData.extendedBolusDialogText) }
|
||||||
}
|
}
|
||||||
binding.infoLayout.extendedLayout.visibility = (overviewData.extendedBolus != null && !pump.isFakingTempsByExtendedBoluses).toVisibility()
|
binding.infoLayout.extendedLayout.visibility = (iobCobCalculator.getExtendedBolus(dateUtil.now()) != null && !pump.isFakingTempsByExtendedBoluses).toVisibility()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,14 +91,6 @@ class OverviewPlugin @Inject constructor(
|
||||||
.toObservable(EventIobCalculationProgress::class.java)
|
.toObservable(EventIobCalculationProgress::class.java)
|
||||||
.observeOn(aapsSchedulers.io)
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ overviewData.calcProgress = it.progress; overviewBus.send(EventUpdateOverview("EventIobCalculationProgress", OverviewData.Property.CALC_PROGRESS)) }, fabricPrivacy::logException)
|
.subscribe({ overviewData.calcProgress = it.progress; overviewBus.send(EventUpdateOverview("EventIobCalculationProgress", OverviewData.Property.CALC_PROGRESS)) }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
|
||||||
.toObservable(EventTempBasalChange::class.java)
|
|
||||||
.observeOn(aapsSchedulers.io)
|
|
||||||
.subscribe({ loadTemporaryBasal("EventTempBasalChange") }, fabricPrivacy::logException)
|
|
||||||
disposable += rxBus
|
|
||||||
.toObservable(EventExtendedBolusChange::class.java)
|
|
||||||
.observeOn(aapsSchedulers.io)
|
|
||||||
.subscribe({ loadExtendedBolus("EventExtendedBolusChange") }, fabricPrivacy::logException)
|
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventNewBG::class.java)
|
.toObservable(EventNewBG::class.java)
|
||||||
.observeOn(aapsSchedulers.io)
|
.observeOn(aapsSchedulers.io)
|
||||||
|
@ -272,8 +264,6 @@ class OverviewPlugin @Inject constructor(
|
||||||
private fun loadAll(from: String) {
|
private fun loadAll(from: String) {
|
||||||
loadBg(from)
|
loadBg(from)
|
||||||
loadProfile(from)
|
loadProfile(from)
|
||||||
loadTemporaryBasal(from)
|
|
||||||
loadExtendedBolus(from)
|
|
||||||
loadTemporaryTarget(from)
|
loadTemporaryTarget(from)
|
||||||
loadIobCobResults(from)
|
loadIobCobResults(from)
|
||||||
loadAsData(from)
|
loadAsData(from)
|
||||||
|
@ -290,16 +280,6 @@ class OverviewPlugin @Inject constructor(
|
||||||
overviewBus.send(EventUpdateOverview(from, OverviewData.Property.PROFILE))
|
overviewBus.send(EventUpdateOverview(from, OverviewData.Property.PROFILE))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadTemporaryBasal(from: String) {
|
|
||||||
overviewData.temporaryBasal = iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())
|
|
||||||
overviewBus.send(EventUpdateOverview(from, OverviewData.Property.TEMPORARY_BASAL))
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun loadExtendedBolus(from: String) {
|
|
||||||
overviewData.extendedBolus = iobCobCalculator.getExtendedBolus(dateUtil.now())
|
|
||||||
overviewBus.send(EventUpdateOverview(from, OverviewData.Property.EXTENDED_BOLUS))
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun loadTemporaryTarget(from: String) {
|
private fun loadTemporaryTarget(from: String) {
|
||||||
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
|
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
|
||||||
if (tempTarget is ValueWrapper.Existing) overviewData.temporaryTarget = tempTarget.value
|
if (tempTarget is ValueWrapper.Existing) overviewData.temporaryTarget = tempTarget.value
|
||||||
|
|
Loading…
Reference in a new issue