Skip to content

Commit

Permalink
Fix ViewAttachEventsObservable not observing observer contract
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Nov 18, 2017
1 parent cb432a8 commit 07f0f1e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ final class ViewAttachEventsObservable extends Observable<ViewLifecycleEvent> {
}

@Override protected void subscribeActual(Observer<? super ViewLifecycleEvent> 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;
Expand All @@ -46,8 +48,6 @@ final class ViewAttachEventsObservable extends Observable<ViewLifecycleEvent> {
// Emit the last event, like a behavior subject
observer.onNext(ViewLifecycleEvent.ATTACH);
}
Listener listener = new Listener(view, observer);
observer.onSubscribe(listener);
view.addOnAttachStateChangeListener(listener);
}

Expand Down

0 comments on commit 07f0f1e

Please sign in to comment.