From 370b504d749924e9a1e789d0f7231e942bff335d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 29 Nov 2021 22:36:20 +0100 Subject: [PATCH] improve notification dismiss --- .../plugins/general/overview/OverviewPlugin.kt | 4 ++-- .../overview/notifications/NotificationStore.kt | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) 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 fc41c0c5b4..d44ef07cdf 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 @@ -77,14 +77,14 @@ class OverviewPlugin @Inject constructor( .observeOn(aapsSchedulers.io) .subscribe({ n -> if (notificationStore.add(n.notification)) - rxBus.send(EventUpdateOverviewNotification("EventNewNotification")) + overviewBus.send(EventUpdateOverviewNotification("EventNewNotification")) }, fabricPrivacy::logException) disposable += rxBus .toObservable(EventDismissNotification::class.java) .observeOn(aapsSchedulers.io) .subscribe({ n -> if (notificationStore.remove(n.id)) - rxBus.send(EventUpdateOverviewNotification("EventDismissNotification")) + overviewBus.send(EventUpdateOverviewNotification("EventDismissNotification")) }, fabricPrivacy::logException) disposable += rxBus .toObservable(EventIobCalculationProgress::class.java) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt index fa7cdfc9c8..df65d1209d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt @@ -14,13 +14,12 @@ import androidx.core.app.NotificationCompat import androidx.recyclerview.widget.RecyclerView import info.nightscout.androidaps.R import info.nightscout.androidaps.databinding.OverviewNotificationItemBinding -import info.nightscout.androidaps.events.EventRefreshOverview +import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.IconsProvider import info.nightscout.androidaps.interfaces.NotificationHolder import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBus -import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification +import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewNotification import info.nightscout.androidaps.services.AlarmSoundServiceHelper import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -33,13 +32,13 @@ import javax.inject.Singleton class NotificationStore @Inject constructor( private val aapsLogger: AAPSLogger, private val sp: SP, - private val rxBus: RxBus, private val rh: ResourceHelper, private val context: Context, private val iconsProvider: IconsProvider, private val alarmSoundServiceHelper: AlarmSoundServiceHelper, private val dateUtil: DateUtil, - private val notificationHolder: NotificationHolder + private val notificationHolder: NotificationHolder, + private val activePlugin: ActivePlugin ) { private var store: MutableList = ArrayList() @@ -186,7 +185,7 @@ class NotificationStore @Inject constructor( val notification = it.tag as Notification notification.contextForAction = itemView.context notification.action?.run() - if (remove(notification.id)) rxBus.send(EventRefreshOverview("NotificationCleared")) + if (remove(notification.id)) activePlugin.activeOverview.overviewBus.send(EventUpdateOverviewNotification("NotificationCleared")) } } }