From 389ef018618ae4365cfacf61d2794d38ef2c4d89 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 30 Dec 2019 19:46:11 +0100 Subject: [PATCH] resolve cyclic dependency --- .../androidaps/plugins/general/wear/ActionStringHandler.kt | 7 ++++--- .../androidaps/plugins/general/wear/WearPlugin.kt | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt index bbdcddd7bc..3093500878 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.general.wear import android.app.NotificationManager import android.content.Context +import dagger.Lazy import info.nightscout.androidaps.Config import info.nightscout.androidaps.Constants import info.nightscout.androidaps.MainApp @@ -50,7 +51,7 @@ class ActionStringHandler @Inject constructor( private val constraintChecker: ConstraintChecker, private val profileFunction: ProfileFunction, private val mainApp: MainApp, - private val loopPlugin: LoopPlugin, + private val loopPlugin: Lazy, private val wearPlugin: WearPlugin, private val treatmentsPlugin: TreatmentsPlugin, private val configBuilderPlugin: ConfigBuilderPlugin, @@ -390,7 +391,7 @@ class ActionStringHandler @Inject constructor( get() { var ret = "" // decide if enabled/disabled closed/open; what Plugin as APS? - if (loopPlugin.isEnabled(loopPlugin.getType())) { + if (loopPlugin.get().isEnabled(loopPlugin.get().getType())) { ret += if (constraintChecker.isClosedLoopAllowed().value()) { "CLOSED LOOP\n" } else { @@ -500,7 +501,7 @@ class ActionStringHandler @Inject constructor( } else if ("dismissoverviewnotification" == act[0]) { rxBus.send(EventDismissNotification(SafeParse.stringToInt(act[1]))) } else if ("changeRequest" == act[0]) { - loopPlugin.acceptChangeRequest() + loopPlugin.get().acceptChangeRequest() val notificationManager = mainApp.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager notificationManager.cancel(Constants.notificationID) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt index 421e28b4d6..342b023343 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.plugins.general.wear import android.content.Intent +import dagger.Lazy import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.events.* @@ -15,8 +16,8 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewB import info.nightscout.androidaps.plugins.general.wear.wearintegration.WatchUpdaterService import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.resources.ResourceHelper +import info.nightscout.androidaps.utils.sharedPreferences.SP import io.reactivex.disposables.CompositeDisposable import io.reactivex.schedulers.Schedulers import javax.inject.Inject @@ -28,7 +29,7 @@ class WearPlugin internal @Inject constructor( private val resourceHelper: ResourceHelper, private val sp: SP, private val mainApp: MainApp, - private val loopPlugin: LoopPlugin + private val loopPlugin: Lazy ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(WearFragment::class.java.name) @@ -77,7 +78,7 @@ class WearPlugin internal @Inject constructor( disposable.add(rxBus .toObservable(EventRefreshOverview::class.java) .observeOn(Schedulers.io()) - .subscribe({ event: EventRefreshOverview? -> if (WatchUpdaterService.shouldReportLoopStatus(loopPlugin.isEnabled(PluginType.LOOP))) sendDataToWatch(true, false, false) }) { FabricPrivacy.logException(it) }) + .subscribe({ event: EventRefreshOverview? -> if (WatchUpdaterService.shouldReportLoopStatus(loopPlugin.get().isEnabled(PluginType.LOOP))) sendDataToWatch(true, false, false) }) { FabricPrivacy.logException(it) }) disposable.add(rxBus .toObservable(EventBolusRequested::class.java) .observeOn(Schedulers.io())