reset cached data on db reset
This commit is contained in:
parent
fcf7faa3e0
commit
c3aea16c72
|
@ -16,11 +16,13 @@ import info.nightscout.androidaps.events.EventNewBG
|
|||
import info.nightscout.androidaps.insight.database.InsightDatabase
|
||||
import info.nightscout.androidaps.interfaces.DataSyncSelector
|
||||
import info.nightscout.androidaps.interfaces.ImportExportPrefs
|
||||
import info.nightscout.androidaps.interfaces.IobCobCalculator
|
||||
import info.nightscout.androidaps.interfaces.PumpSync
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity
|
||||
import info.nightscout.androidaps.plugins.general.overview.OverviewData
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
|
@ -44,6 +46,8 @@ class MaintenanceFragment : DaggerFragment() {
|
|||
@Inject lateinit var uel: UserEntryLogger
|
||||
@Inject lateinit var dataSyncSelector: DataSyncSelector
|
||||
@Inject lateinit var pumpSync: PumpSync
|
||||
@Inject lateinit var iobCobCalculator: IobCobCalculator
|
||||
@Inject lateinit var overviewData: OverviewData
|
||||
|
||||
private val compositeDisposable = CompositeDisposable()
|
||||
|
||||
|
@ -77,6 +81,9 @@ class MaintenanceFragment : DaggerFragment() {
|
|||
insightDatabase.clearAllTables()
|
||||
dataSyncSelector.resetToNextFullSync()
|
||||
pumpSync.connectNewPump()
|
||||
overviewData.reset()
|
||||
iobCobCalculator.ads.reset()
|
||||
iobCobCalculator.clearCache()
|
||||
}
|
||||
.subscribeOn(aapsSchedulers.io)
|
||||
.observeOn(aapsSchedulers.main)
|
||||
|
|
|
@ -71,6 +71,44 @@ class OverviewData @Inject constructor(
|
|||
var fromTime: Long = 0
|
||||
var endTime: Long = 0
|
||||
|
||||
fun reset() {
|
||||
profile = null
|
||||
profileName = null
|
||||
profileNameWithRemainingTime = null
|
||||
calcProgress = ""
|
||||
lastBg = null
|
||||
temporaryBasal = null
|
||||
extendedBolus = null
|
||||
bolusIob = null
|
||||
basalIob = null
|
||||
cobInfo = null
|
||||
lastCarbsTime = 0L
|
||||
temporaryTarget = null
|
||||
lastAutosensData = null
|
||||
bgReadingsArray = ArrayList()
|
||||
bucketedGraphSeries = PointsWithLabelGraphSeries()
|
||||
bgReadingGraphSeries = PointsWithLabelGraphSeries()
|
||||
predictionsGraphSeries = PointsWithLabelGraphSeries()
|
||||
baseBasalGraphSeries = LineGraphSeries()
|
||||
tempBasalGraphSeries = LineGraphSeries()
|
||||
basalLineGraphSeries = LineGraphSeries()
|
||||
absoluteBasalGraphSeries = LineGraphSeries()
|
||||
activitySeries = FixedLineGraphSeries()
|
||||
activityPredictionSeries = FixedLineGraphSeries()
|
||||
iobSeries = FixedLineGraphSeries()
|
||||
absIobSeries = FixedLineGraphSeries()
|
||||
iobPredictions1Series = PointsWithLabelGraphSeries()
|
||||
iobPredictions2Series = PointsWithLabelGraphSeries()
|
||||
minusBgiSeries = FixedLineGraphSeries()
|
||||
minusBgiHistSeries = FixedLineGraphSeries()
|
||||
cobSeries = FixedLineGraphSeries()
|
||||
cobMinFailOverSeries = PointsWithLabelGraphSeries()
|
||||
deviationsSeries = BarGraphSeries()
|
||||
ratioSeries = LineGraphSeries()
|
||||
dsMaxSeries = LineGraphSeries()
|
||||
dsMinSeries = LineGraphSeries()
|
||||
}
|
||||
|
||||
fun initRange() {
|
||||
rangeToDisplay = sp.getInt(R.string.key_rangetodisplay, 6)
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ open class IobCobCalculatorPlugin @Inject constructor(
|
|||
runCalculation(reason, System.currentTimeMillis(), bgDataReload = false, limitDataToOldestAvailable = true, cause = event)
|
||||
}
|
||||
|
||||
fun clearCache() {
|
||||
override fun clearCache() {
|
||||
synchronized(dataLock) {
|
||||
aapsLogger.debug(LTag.AUTOSENS, "Clearing cached data.")
|
||||
iobTable = LongSparseArray()
|
||||
|
|
|
@ -27,6 +27,8 @@ interface IobCobCalculator {
|
|||
fun iobArrayToString(array: Array<IobTotal>): String
|
||||
fun convertToJSONArray(iobArray: Array<IobTotal>): JSONArray
|
||||
|
||||
fun clearCache()
|
||||
|
||||
/**
|
||||
* Calculate CobInfo to now()
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue