From 175f008d3befd6178e4bb47d9d4e943f8355a5b6 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 6 Nov 2021 22:56:34 +0100 Subject: [PATCH] fix screen refresh after unit change --- .../plugins/general/overview/OverviewPlugin.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt index dd528a7aef..0b880c5f19 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt @@ -44,7 +44,6 @@ class OverviewPlugin @Inject constructor( rh: ResourceHelper, private val config: Config, private val dateUtil: DateUtil, - private val profileFunction: ProfileFunction, private val iobCobCalculator: IobCobCalculator, private val repository: AppRepository, private val overviewData: OverviewData, @@ -154,6 +153,18 @@ class OverviewPlugin @Inject constructor( .subscribe({ overviewData.pumpStatus = it.getStatus(rh) }, fabricPrivacy::logException) + disposable += rxBus + .toObservable(EventPreferenceChange::class.java) + .observeOn(aapsSchedulers.io) + .subscribe({ event -> + if (event.isChanged(rh, R.string.key_units)) { + overviewData.reset() + overviewData.prepareBucketedData("EventBucketedDataCreated") + overviewData.prepareBgData("EventBucketedDataCreated") + overviewBus.send(EventUpdateOverview("EventBucketedDataCreated", OverviewData.Property.GRAPH)) + loadAll("EventPreferenceChange") + } + }, fabricPrivacy::logException) Thread { loadAll("onResume") }.start() }