reset cache on ConfigBuilderChange event

This commit is contained in:
Milos Kozak 2017-06-24 15:11:30 +02:00
parent 70aaafa616
commit 129f813de2

View file

@ -25,6 +25,7 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.events.EventConfigBuilderChange;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventNewBasalProfile;
import info.nightscout.androidaps.events.EventPreferenceChange;
@ -597,6 +598,21 @@ public class IobCobCalculatorPlugin implements PluginBase {
}
}
@Subscribe
public void onStatusEvent(EventConfigBuilderChange ev) {
synchronized (dataLock) {
log.debug("Invalidating cached data because of configuration change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
iobTable = new LongSparseArray<>();
autosensDataTable = new LongSparseArray<>();
}
sHandler.post(new Runnable() {
@Override
public void run() {
calculateSensitivityData();
}
});
}
// When historical data is changed (comming from NS etc) finished calculations after this date must be invalidated
@Subscribe
public void onNewHistoryData(EventNewHistoryData ev) {