@Test public void cancelSkipsIfViewTreeObserverIsDead() { ImageView target = mockFitImageViewTarget(false); RequestCreator creator = mock(RequestCreator.class); DeferredRequestCreator request = new DeferredRequestCreator(creator, target); request.cancel(); verify(target.getViewTreeObserver(), never()).removeOnPreDrawListener(request); }
void cancel() { creator.clearTag(); callback = null; ImageView target = this.target.get(); if (target == null) { return; } this.target.clear(); if (attachListener != null) { target.removeOnAttachStateChangeListener(attachListener); attachListener = null; } else { ViewTreeObserver vto = target.getViewTreeObserver(); if (!vto.isAlive()) { return; } vto.removeOnPreDrawListener(this); } }
DeferredRequestCreator implements ViewTreeObserver.OnPreDrawListener { void cancel() { creator.clearTag(); callback = null; ImageView target = this.target.get(); if (target == null) { return; } this.target.clear(); if (attachListener != null) { target.removeOnAttachStateChangeListener(attachListener); attachListener = null; } else { ViewTreeObserver vto = target.getViewTreeObserver(); if (!vto.isAlive()) { return; } vto.removeOnPreDrawListener(this); } } }
DeferredRequestCreator implements ViewTreeObserver.OnPreDrawListener { void cancel() { creator.clearTag(); callback = null; ImageView target = this.target.get(); if (target == null) { return; } this.target.clear(); if (attachListener != null) { target.removeOnAttachStateChangeListener(attachListener); attachListener = null; } else { ViewTreeObserver vto = target.getViewTreeObserver(); if (!vto.isAlive()) { return; } vto.removeOnPreDrawListener(this); } } @VisibleForTesting  DeferredRequestCreator(RequestCreator creator, ImageView target);   DeferredRequestCreator(RequestCreator creator, ImageView target, Callback callback); }
DeferredRequestCreator implements ViewTreeObserver.OnPreDrawListener { void cancel() { creator.clearTag(); callback = null; ImageView target = this.target.get(); if (target == null) { return; } this.target.clear(); if (attachListener != null) { target.removeOnAttachStateChangeListener(attachListener); attachListener = null; } else { ViewTreeObserver vto = target.getViewTreeObserver(); if (!vto.isAlive()) { return; } vto.removeOnPreDrawListener(this); } } @VisibleForTesting  DeferredRequestCreator(RequestCreator creator, ImageView target);   DeferredRequestCreator(RequestCreator creator, ImageView target, Callback callback); @Override boolean onPreDraw(); }
DeferredRequestCreator implements ViewTreeObserver.OnPreDrawListener { void cancel() { creator.clearTag(); callback = null; ImageView target = this.target.get(); if (target == null) { return; } this.target.clear(); if (attachListener != null) { target.removeOnAttachStateChangeListener(attachListener); attachListener = null; } else { ViewTreeObserver vto = target.getViewTreeObserver(); if (!vto.isAlive()) { return; } vto.removeOnPreDrawListener(this); } } @VisibleForTesting  DeferredRequestCreator(RequestCreator creator, ImageView target);   DeferredRequestCreator(RequestCreator creator, ImageView target, Callback callback); @Override boolean onPreDraw();  }