@Implementation public void addOnAttachStateChangeListener(OnAttachStateChangeListener listener) { attachStateListeners.add(listener); }
@Implementation public void removeOnAttachStateChangeListener(OnAttachStateChangeListener listener) { attachStateListeners.remove(listener); }
@Implementation public void onAttachedToWindow() { for (OnAttachStateChangeListener listener : attachStateListeners) { listener.onViewAttachedToWindow(view); } }
@Implementation public void onDetachedFromWindow() { for (OnAttachStateChangeListener listener : attachStateListeners) { listener.onViewDetachedFromWindow(view); } }
/** * @see View#removeOnAttachStateChangeListener(OnAttachStateChangeListener) */ public W removeOnAttachStateChangeListener(OnAttachStateChangeListener listener) { mView.removeOnAttachStateChangeListener(listener); return (W)this; }
/** * @see View#addOnAttachStateChangeListener(OnAttachStateChangeListener) */ public W addOnAttachStateChangeListener(OnAttachStateChangeListener listener) { mView.addOnAttachStateChangeListener(listener); return (W)this; }
private static List<OnAttachStateChangeListener> getAttachStateListeners(View view) { Object listenerInfo = ReflectionHelpers.callInstanceMethod(view, "getListenerInfo"); return ReflectionHelpers.getField(listenerInfo, "mOnAttachStateChangeListeners"); }
public Disposable onAttachStateChange(final OnAttachStateChangeListener onNext) { return onAttachStateChange(onNext, Fu.ON_ERROR_MISSING); }
public Disposable onAttachStateChange(final OnAttachStateChangeListener onNext, final Consumer<? super Exception> onError) { return onAttachStateChange(onNext, onError, Fu.EMPTY_ACTION); }