cleanup
This commit is contained in:
parent
b4cdd4e7b3
commit
86ceda76c8
|
@ -8,13 +8,15 @@ 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() {
|
||||
private val disposable = CompositeDisposable()
|
||||
protected val disposable = CompositeDisposable()
|
||||
|
||||
private val _isActionExecutingLiveData = MutableLiveData(false)
|
||||
val isActionExecutingLiveData: LiveData<Boolean> = _isActionExecutingLiveData
|
||||
|
@ -24,7 +26,7 @@ abstract class ActionViewModelBase(
|
|||
|
||||
fun executeAction() {
|
||||
_isActionExecutingLiveData.postValue(true)
|
||||
val subscription = doExecuteAction().subscribeBy(
|
||||
disposable += doExecuteAction().subscribeBy(
|
||||
onSuccess = { result ->
|
||||
_isActionExecutingLiveData.postValue(false)
|
||||
_actionResultLiveData.postValue(result)
|
||||
|
@ -35,7 +37,6 @@ abstract class ActionViewModelBase(
|
|||
_actionResultLiveData.postValue(PumpEnactResult(injector).success(false).comment(
|
||||
throwable.message ?: "Caught exception in while executing action in ActionViewModelBase"))
|
||||
})
|
||||
disposable.add(subscription)
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
|
|
|
@ -15,6 +15,8 @@ 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
|
||||
|
||||
|
@ -26,8 +28,6 @@ class DashInitializePodViewModel @Inject constructor(
|
|||
private val podStateManager: OmnipodDashPodStateManager,
|
||||
private val resourceHelper: ResourceHelper
|
||||
) : InitializePodViewModel(injector, logger) {
|
||||
private val disposable = CompositeDisposable()
|
||||
|
||||
override fun isPodInAlarm(): Boolean = false // TODO
|
||||
|
||||
override fun isPodActivationTimeExceeded(): Boolean = false // TODO
|
||||
|
@ -43,7 +43,7 @@ class DashInitializePodViewModel @Inject constructor(
|
|||
} else
|
||||
null
|
||||
|
||||
val subscription = omnipodManager.activatePodPart1(lowReservoirAlertTrigger).subscribeBy(
|
||||
super.disposable += omnipodManager.activatePodPart1(lowReservoirAlertTrigger).subscribeBy(
|
||||
onNext = { podEvent ->
|
||||
logger.debug(
|
||||
LTag.PUMP,
|
||||
|
@ -64,14 +64,8 @@ class DashInitializePodViewModel @Inject constructor(
|
|||
source.onSuccess(PumpEnactResult(injector).success(true))
|
||||
}
|
||||
)
|
||||
disposable.add(subscription)
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
disposable.clear()
|
||||
}
|
||||
|
||||
@StringRes
|
||||
override fun getTitleId(): Int = R.string.omnipod_common_pod_activation_wizard_initialize_pod_title
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ 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
|
||||
|
||||
|
@ -37,8 +39,6 @@ class DashInsertCannulaViewModel @Inject constructor(
|
|||
injector: HasAndroidInjector,
|
||||
logger: AAPSLogger
|
||||
) : InsertCannulaViewModel(injector, logger) {
|
||||
private val disposable = CompositeDisposable()
|
||||
|
||||
override fun isPodInAlarm(): Boolean = false // TODO
|
||||
|
||||
override fun isPodActivationTimeExceeded(): Boolean = false // TODO
|
||||
|
@ -65,7 +65,8 @@ class DashInsertCannulaViewModel @Inject constructor(
|
|||
else
|
||||
null
|
||||
|
||||
val subscription = omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown).subscribeBy(
|
||||
super.disposable += omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown)
|
||||
.subscribeBy(
|
||||
onNext = { podEvent ->
|
||||
logger.debug(
|
||||
LTag.PUMP,
|
||||
|
@ -103,15 +104,9 @@ class DashInsertCannulaViewModel @Inject constructor(
|
|||
source.onSuccess(PumpEnactResult(injector).success(true))
|
||||
}
|
||||
)
|
||||
disposable.add(subscription)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
disposable.clear()
|
||||
}
|
||||
|
||||
@StringRes
|
||||
override fun getTitleId(): Int = R.string.omnipod_common_pod_activation_wizard_insert_cannula_title
|
||||
|
||||
|
|
Loading…
Reference in a new issue