@Override public void onLoadCleared(Drawable placeholder) { target.onLoadCleared(placeholder); }
@Override public void onLoadCleared(Drawable placeholder) { if (target != null) target.onLoadCleared(placeholder); }
@Test public void clear_doesNotNotifyTarget_ifRequestCoordinatorReturnsFalseForCanClear() { when(builder.requestCoordinator.canNotifyCleared(any(Request.class))).thenReturn(false); SingleRequest<List> request = builder.build(); request.clear(); verify(builder.target, never()).onLoadCleared(any(Drawable.class)); }
@Test public void testDoesNotNotifyTargetTwiceIfClearedTwiceInARow() { SingleRequest<List> request = builder.build(); request.clear(); request.clear(); verify(builder.target, times(1)).onLoadCleared(any(Drawable.class)); }
@Test public void clear_notifiesTarget() { SingleRequest<List> request = builder.build(); request.clear(); verify(builder.target).onLoadCleared(any(Drawable.class)); }
/** * Cancels the current load if it is in progress, clears any resources held onto by the request * and replaces the loaded resource if the load completed with the placeholder. * * <p>Cleared requests can be restarted with a subsequent call to {@link #begin()} * * @see #cancel() */ @Override public synchronized void clear() { assertNotCallingCallbacks(); stateVerifier.throwIfRecycled(); if (status == Status.CLEARED) { return; } cancel(); // Resource must be released before canNotifyStatusChanged is called. if (resource != null) { releaseResource(resource); } if (canNotifyCleared()) { target.onLoadCleared(getPlaceholderDrawable()); } status = Status.CLEARED; }
@Override public void onLoadCleared(Drawable placeholder) { target.onLoadCleared(placeholder); }
/** * Cancels the current load if it is in progress, clears any resources held onto by the request and replaces * the loaded resource if the load completed with the placeholder. * * <p> * Cleared requests can be restarted with a subsequent call to {@link #begin()} * </p> * * @see #cancel() */ @Override public void clear() { Util.assertMainThread(); if (status == Status.CLEARED) { return; } cancel(); // Resource must be released before canNotifyStatusChanged is called. if (resource != null) { releaseResource(resource); } if (canNotifyStatusChanged()) { target.onLoadCleared(getPlaceholderDrawable()); } // Must be after cancel(). status = Status.CLEARED; }
@Override public void onLoadCleared(Drawable placeholder) { if (target != null) target.onLoadCleared(placeholder); }
@Override public void onLoadCleared(Drawable placeholder) { target.onLoadCleared(placeholder); }
/** * Cancels the current load if it is in progress, clears any resources held onto by the request * and replaces the loaded resource if the load completed with the placeholder. * * <p> Cleared requests can be restarted with a subsequent call to {@link #begin()} </p> * * @see #cancel() */ @Override public void clear() { Util.assertMainThread(); assertNotCallingCallbacks(); if (status == Status.CLEARED) { return; } cancel(); // Resource must be released before canNotifyStatusChanged is called. if (resource != null) { releaseResource(resource); } if (canNotifyStatusChanged()) { target.onLoadCleared(getPlaceholderDrawable()); } // Must be after cancel(). status = Status.CLEARED; }