From 75101b1abf5a5d3b2f1799b40b3961b38cd9c1bd Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 2 Nov 2020 12:26:41 +0700 Subject: [PATCH] fix dialog control close dialog when lifecycle state is DESTROYED --- .../com/alexdeww/reactiveviewmodel/widget/DialogControl.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reactiveviewmodel/src/main/java/com/alexdeww/reactiveviewmodel/widget/DialogControl.kt b/reactiveviewmodel/src/main/java/com/alexdeww/reactiveviewmodel/widget/DialogControl.kt index 807e7d5..3adca1b 100644 --- a/reactiveviewmodel/src/main/java/com/alexdeww/reactiveviewmodel/widget/DialogControl.kt +++ b/reactiveviewmodel/src/main/java/com/alexdeww/reactiveviewmodel/widget/DialogControl.kt @@ -4,6 +4,7 @@ import android.app.Dialog import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.MediatorLiveData +import androidx.lifecycle.Observer import com.alexdeww.reactiveviewmodel.core.RvmViewComponent import io.reactivex.rxjava3.core.Maybe @@ -106,11 +107,11 @@ private class DialogLiveDataMediator( } } - override fun onInactive() { + override fun removeObserver(observer: Observer) { if (lifecycleOwner.lifecycle.currentState == Lifecycle.State.DESTROYED) { closeDialog() } - super.onInactive() + super.removeObserver(observer) } private fun closeDialog() {