Skip to content

Commit

Permalink
fix dialog control
Browse files Browse the repository at this point in the history
close dialog when lifecycle state is DESTROYED
  • Loading branch information
Alex committed Nov 2, 2020
1 parent 289d3cc commit 75101b1
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -106,11 +107,11 @@ private class DialogLiveDataMediator<T, R>(
}
}

override fun onInactive() {
override fun removeObserver(observer: Observer<in DialogControl.Display>) {
if (lifecycleOwner.lifecycle.currentState == Lifecycle.State.DESTROYED) {
closeDialog()
}
super.onInactive()
super.removeObserver(observer)
}

private fun closeDialog() {
Expand Down

0 comments on commit 75101b1

Please sign in to comment.