From 07f0f1eb77530d9180b33072d3058835920c279f Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Fri, 17 Nov 2017 22:36:21 -0800 Subject: [PATCH] Fix ViewAttachEventsObservable not observing observer contract --- .../uber/autodispose/android/ViewAttachEventsObservable.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 c95193664..7a7c2f3cb 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 @@ -37,6 +37,8 @@ final class ViewAttachEventsObservable extends Observable { } @Override protected void subscribeActual(Observer observer) { + Listener listener = new Listener(view, observer); + observer.onSubscribe(listener); if (!isMainThread()) { observer.onError(new IllegalStateException("Views can only be bound to on the main thread!")); return; @@ -46,8 +48,6 @@ final class ViewAttachEventsObservable extends Observable { // Emit the last event, like a behavior subject observer.onNext(ViewLifecycleEvent.ATTACH); } - Listener listener = new Listener(view, observer); - observer.onSubscribe(listener); view.addOnAttachStateChangeListener(listener); }