From 22ba6835e9edd888137bea2891c3f4503afb2c3e Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Mon, 27 Nov 2017 03:44:31 -0800 Subject: [PATCH] Check if listener is disposed in viewattacheventsobservable --- .../uber/autodispose/android/ViewAttachEventsObservable.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/autodispose-android/src/main/java/com/uber/autodispose/android/ViewAttachEventsObservable.java b/android/autodispose-android/src/main/java/com/uber/autodispose/android/ViewAttachEventsObservable.java index 7a7c2f3cb..17beef1fb 100644 --- a/android/autodispose-android/src/main/java/com/uber/autodispose/android/ViewAttachEventsObservable.java +++ b/android/autodispose-android/src/main/java/com/uber/autodispose/android/ViewAttachEventsObservable.java @@ -49,6 +49,9 @@ final class ViewAttachEventsObservable extends Observable { observer.onNext(ViewLifecycleEvent.ATTACH); } view.addOnAttachStateChangeListener(listener); + if (listener.isDisposed()) { + view.removeOnAttachStateChangeListener(listener); + } } static final class Listener extends MainThreadDisposable