From b077b1d5b1b213930df8e9c264f5444fcce9f224 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 27 Mar 2021 22:47:45 +0100 Subject: [PATCH] load Action String Handler --- .../plugins/general/wear/ActionStringHandler.kt | 8 ++++++-- .../androidaps/plugins/general/wear/WearPlugin.kt | 5 ++++- 2 files changed, 10 insertions(+), 3 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 8216e093fc..1fa4210b9a 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 @@ -59,7 +59,7 @@ class ActionStringHandler @Inject constructor( private val sp: SP, private val rxBus: RxBusWrapper, private val aapsLogger: AAPSLogger, - aapsSchedulers: AapsSchedulers, + private val aapsSchedulers: AapsSchedulers, private val resourceHelper: ResourceHelper, private val injector: HasAndroidInjector, private val context: Context, @@ -92,7 +92,7 @@ class ActionStringHandler @Inject constructor( private val disposable = CompositeDisposable() - init { + fun setup() { disposable += rxBus .toObservable(EventWearInitiateAction::class.java) .observeOn(aapsSchedulers.main) @@ -104,6 +104,10 @@ class ActionStringHandler @Inject constructor( .subscribe({ handleConfirmation(it.action) }, fabricPrivacy::logException) } + fun tearDown(){ + disposable.clear() + } + @Synchronized private fun handleInitiate(actionString: String) { if (!sp.getBoolean(R.string.key_wear_control, false)) return 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 f3cdd7a7f2..74bd00d7f0 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 @@ -35,7 +35,8 @@ class WearPlugin @Inject constructor( private val mainApp: MainApp, private val fabricPrivacy: FabricPrivacy, private val loopPlugin: Lazy, - private val rxBus: RxBusWrapper + private val rxBus: RxBusWrapper, + private val actionStringHandler: Lazy ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) @@ -127,11 +128,13 @@ class WearPlugin @Inject constructor( mainApp.startService(intent) } }, fabricPrivacy::logException)) + actionStringHandler.get().setup() } override fun onStop() { disposable.clear() super.onStop() + actionStringHandler.get().setup() } private fun sendDataToWatch(status: Boolean, basals: Boolean, bgValue: Boolean) {