NSC: fix units update

This commit is contained in:
Milos Kozak 2023-08-17 20:31:27 +02:00
parent a04076ac25
commit 60d3fb657a
3 changed files with 26 additions and 1 deletions

View file

@ -64,6 +64,7 @@ class OverviewDataImpl @Inject constructor(
pumpStatus = "" pumpStatus = ""
calcProgressPct = 100 calcProgressPct = 100
bgReadingsArray = ArrayList() bgReadingsArray = ArrayList()
maxBgValue = Double.MIN_VALUE
bucketedGraphSeries = PointsWithLabelGraphSeries() bucketedGraphSeries = PointsWithLabelGraphSeries()
bgReadingGraphSeries = PointsWithLabelGraphSeries() bgReadingGraphSeries = PointsWithLabelGraphSeries()
predictionsGraphSeries = PointsWithLabelGraphSeries() predictionsGraphSeries = PointsWithLabelGraphSeries()
@ -71,22 +72,36 @@ class OverviewDataImpl @Inject constructor(
tempBasalGraphSeries = LineGraphSeries() tempBasalGraphSeries = LineGraphSeries()
basalLineGraphSeries = LineGraphSeries() basalLineGraphSeries = LineGraphSeries()
absoluteBasalGraphSeries = LineGraphSeries() absoluteBasalGraphSeries = LineGraphSeries()
temporaryTargetSeries = LineGraphSeries()
maxIAValue = 0.0
activitySeries = FixedLineGraphSeries() activitySeries = FixedLineGraphSeries()
activityPredictionSeries = FixedLineGraphSeries() activityPredictionSeries = FixedLineGraphSeries()
maxIobValueFound = Double.MIN_VALUE
iobSeries = FixedLineGraphSeries() iobSeries = FixedLineGraphSeries()
absIobSeries = FixedLineGraphSeries() absIobSeries = FixedLineGraphSeries()
iobPredictions1Series = PointsWithLabelGraphSeries() iobPredictions1Series = PointsWithLabelGraphSeries()
//iobPredictions2Series = PointsWithLabelGraphSeries() //iobPredictions2Series = PointsWithLabelGraphSeries()
maxBGIValue = Double.MIN_VALUE
minusBgiSeries = FixedLineGraphSeries() minusBgiSeries = FixedLineGraphSeries()
minusBgiHistSeries = FixedLineGraphSeries() minusBgiHistSeries = FixedLineGraphSeries()
maxCobValueFound = Double.MIN_VALUE
cobSeries = FixedLineGraphSeries() cobSeries = FixedLineGraphSeries()
cobMinFailOverSeries = PointsWithLabelGraphSeries() cobMinFailOverSeries = PointsWithLabelGraphSeries()
maxDevValueFound = Double.MIN_VALUE
deviationsSeries = BarGraphSeries() deviationsSeries = BarGraphSeries()
maxRatioValueFound = 5.0 //even if sens data equals 0 for all the period, minimum scale is between 95% and 105%
minRatioValueFound = -maxRatioValueFound
ratioSeries = LineGraphSeries() ratioSeries = LineGraphSeries()
maxFromMaxValueFound = Double.MIN_VALUE
maxFromMinValueFound = Double.MIN_VALUE
dsMaxSeries = LineGraphSeries() dsMaxSeries = LineGraphSeries()
dsMinSeries = LineGraphSeries() dsMinSeries = LineGraphSeries()
maxTreatmentsValue = 0.0
treatmentsSeries = PointsWithLabelGraphSeries() treatmentsSeries = PointsWithLabelGraphSeries()
maxEpsValue = 0.0
epsSeries = PointsWithLabelGraphSeries() epsSeries = PointsWithLabelGraphSeries()
maxTherapyEventValue = 0.0
therapyEventSeries = PointsWithLabelGraphSeries()
heartRateGraphSeries = LineGraphSeries() heartRateGraphSeries = LineGraphSeries()
} }

View file

@ -103,7 +103,10 @@ class MaintenanceFragment : DaggerFragment() {
.subscribeOn(aapsSchedulers.io) .subscribeOn(aapsSchedulers.io)
.subscribeBy( .subscribeBy(
onError = { aapsLogger.error("Error clearing databases", it) }, onError = { aapsLogger.error("Error clearing databases", it) },
onComplete = { rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.utils.R.string.key_units))) } onComplete = {
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.utils.R.string.key_units)))
activity.recreate()
}
) )
uel.log(Action.RESET_DATABASES, Sources.Maintenance) uel.log(Action.RESET_DATABASES, Sources.Maintenance)
}) })

View file

@ -30,6 +30,7 @@ import info.nightscout.plugins.general.overview.notifications.events.EventUpdate
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventDismissNotification import info.nightscout.rx.events.EventDismissNotification
import info.nightscout.rx.events.EventNewHistoryData
import info.nightscout.rx.events.EventPumpStatusChanged import info.nightscout.rx.events.EventPumpStatusChanged
import info.nightscout.rx.events.EventUpdateOverviewCalcProgress import info.nightscout.rx.events.EventUpdateOverviewCalcProgress
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -187,6 +188,7 @@ class OverviewPlugin @Inject constructor(
.putInt(info.nightscout.core.utils.R.string.key_boluswizard_percentage, sp, rh) .putInt(info.nightscout.core.utils.R.string.key_boluswizard_percentage, sp, rh)
override fun applyConfiguration(configuration: JSONObject) { override fun applyConfiguration(configuration: JSONObject) {
val previousUnits = sp.getString(info.nightscout.core.utils.R.string.key_units, "random")
configuration configuration
.storeString(info.nightscout.core.utils.R.string.key_units, sp, rh) .storeString(info.nightscout.core.utils.R.string.key_units, sp, rh)
.storeString(info.nightscout.core.utils.R.string.key_quickwizard, sp, rh) .storeString(info.nightscout.core.utils.R.string.key_quickwizard, sp, rh)
@ -213,5 +215,10 @@ class OverviewPlugin @Inject constructor(
.storeDouble(R.string.key_statuslights_bat_warning, sp, rh) .storeDouble(R.string.key_statuslights_bat_warning, sp, rh)
.storeDouble(R.string.key_statuslights_bat_critical, sp, rh) .storeDouble(R.string.key_statuslights_bat_critical, sp, rh)
.storeInt(info.nightscout.core.utils.R.string.key_boluswizard_percentage, sp, rh) .storeInt(info.nightscout.core.utils.R.string.key_boluswizard_percentage, sp, rh)
val newUnits = sp.getString(info.nightscout.core.utils.R.string.key_units, "new")
if (previousUnits != newUnits) {
overviewData.reset()
rxBus.send(EventNewHistoryData(0L, reloadBgData = true))
}
} }
} }