diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt index 9f58616ed9..1a4b228398 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt @@ -145,7 +145,7 @@ abstract class Trigger(val injector: HasAndroidInjector) { TriggerWifiSsid::class.java.simpleName -> TriggerWifiSsid(injector).fromJSON( data.toString() ) - else -> throw ClassNotFoundException(type) + else -> TriggerConnector(injector) } } diff --git a/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/common/viewmodel/ActionViewModelBase.kt b/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/common/viewmodel/ActionViewModelBase.kt index 91ee56d19d..d3c0ac8aaa 100644 --- a/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/common/viewmodel/ActionViewModelBase.kt +++ b/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/common/viewmodel/ActionViewModelBase.kt @@ -7,12 +7,16 @@ import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import io.reactivex.Single +import io.reactivex.disposables.CompositeDisposable +import io.reactivex.rxkotlin.addTo +import io.reactivex.rxkotlin.plusAssign import io.reactivex.rxkotlin.subscribeBy abstract class ActionViewModelBase( protected val injector: HasAndroidInjector, protected val logger: AAPSLogger ) : ViewModelBase() { + protected val disposable = CompositeDisposable() private val _isActionExecutingLiveData = MutableLiveData(false) val isActionExecutingLiveData: LiveData = _isActionExecutingLiveData @@ -22,7 +26,7 @@ abstract class ActionViewModelBase( fun executeAction() { _isActionExecutingLiveData.postValue(true) - val disposable = doExecuteAction().subscribeBy( + disposable += doExecuteAction().subscribeBy( onSuccess = { result -> _isActionExecutingLiveData.postValue(false) _actionResultLiveData.postValue(result) @@ -35,5 +39,11 @@ abstract class ActionViewModelBase( }) } + override fun onCleared() { + super.onCleared() + disposable.clear() + } + + protected abstract fun doExecuteAction(): Single } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt index 83b0796ffe..4f49c6f4f1 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt @@ -111,13 +111,12 @@ class OmnipodDashPumpPlugin @Inject constructor( updatePodWarnings() aapsLogger.info(LTag.PUMP, "statusChecker") - createFakeTBRWhenNoActivePod() + val err = createFakeTBRWhenNoActivePod() .subscribeOn(aapsSchedulers.io) - .subscribeBy( - onError = { - aapsLogger.warn(LTag.PUMP, "Error on createFakeTBRWhenNoActivePod=$it") - } - ) + .blockingGet() + err?.let { + aapsLogger.warn(LTag.PUMP, "Error on createFakeTBRWhenNoActivePod=$it") + } handler.postDelayed(statusChecker, STATUS_CHECK_INTERVAL_MS) } } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertConfiguration.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertConfiguration.kt index 3dcc266058..7669f176f7 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertConfiguration.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertConfiguration.kt @@ -17,13 +17,13 @@ class AlertConfiguration( get() { var firstByte = (type.index.toInt() shl 4).toByte() if (enabled) { - firstByte = firstByte or (1 shl 3).toByte() + firstByte = (firstByte.toInt() or (1 shl 3)).toByte() } if (trigger is AlertTrigger.ReservoirVolumeTrigger) { - firstByte = firstByte or (1 shl 2).toByte() + firstByte = (firstByte.toInt() or (1 shl 2)).toByte() } if (autoOff) { - firstByte = firstByte or (1 shl 1).toByte() + firstByte = (firstByte.toInt() or (1 shl 1)).toByte() } firstByte = firstByte or ((durationInMinutes.toInt() shr 8 and 0x01).toByte()) return ByteBuffer.allocate(6) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt index a6faa187f4..78f8c48d8d 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt @@ -14,6 +14,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.I8n import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import io.reactivex.Single +import io.reactivex.disposables.CompositeDisposable +import io.reactivex.rxkotlin.addTo +import io.reactivex.rxkotlin.plusAssign import io.reactivex.rxkotlin.subscribeBy import javax.inject.Inject @@ -40,7 +43,7 @@ class DashInitializePodViewModel @Inject constructor( } else null - omnipodManager.activatePodPart1(lowReservoirAlertTrigger).subscribeBy( + super.disposable += omnipodManager.activatePodPart1(lowReservoirAlertTrigger).subscribeBy( onNext = { podEvent -> logger.debug( LTag.PUMP, diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt index 9a3530f443..a716d2b56b 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt @@ -21,6 +21,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBas import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import io.reactivex.Single +import io.reactivex.disposables.CompositeDisposable +import io.reactivex.rxkotlin.addTo +import io.reactivex.rxkotlin.plusAssign import io.reactivex.rxkotlin.subscribeBy import javax.inject.Inject @@ -36,7 +39,6 @@ class DashInsertCannulaViewModel @Inject constructor( injector: HasAndroidInjector, logger: AAPSLogger ) : InsertCannulaViewModel(injector, logger) { - override fun isPodInAlarm(): Boolean = false // TODO override fun isPodActivationTimeExceeded(): Boolean = false // TODO @@ -63,7 +65,8 @@ class DashInsertCannulaViewModel @Inject constructor( else null - omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown).subscribeBy( + super.disposable += omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown) + .subscribeBy( onNext = { podEvent -> logger.debug( LTag.PUMP,