Interface Target<R>
- Type Parameters:
R- The type of resource the target can display.
- All Superinterfaces:
LifecycleListener
- All Known Subinterfaces:
FutureTarget<R>
- All Known Implementing Classes:
AppWidgetTarget,BaseTarget,BitmapImageViewTarget,BitmapThumbnailImageViewTarget,CustomTarget,CustomViewTarget,DrawableImageViewTarget,DrawableThumbnailImageViewTarget,ImageViewTarget,NotificationTarget,PreloadTarget,RequestFutureTarget,SimpleTarget,ThumbnailImageViewTarget,ViewTarget
The lifecycle events in this class are as follows:
- onLoadStarted
- onResourceReady
- onLoadCleared
- onLoadFailed
The typical lifecycle is onLoadStarted, then onResourceReady or onLoadFailed, then onLoadCleared. However, there are no guarantees. onLoadStarted may not be called if the resource is in memory or if the load will fail because of a null model object. onLoadCleared similarly may never be called if the target is never cleared. See the docs for the individual methods for details.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIndicates that we want the resource in its original unmodified width and/or height. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the current request for this target, should not be called outside of Glide.voidA method to retrieve the size of this target.voidonLoadCleared(Drawable placeholder) A mandatory lifecycle callback that is called when a load is cancelled and its resources are freed.voidonLoadFailed(Drawable errorDrawable) A mandatory lifecycle callback that is called when a load fails.voidonLoadStarted(Drawable placeholder) A lifecycle callback that is called when a load is started.voidonResourceReady(R resource, Transition<? super R> transition) The method that will be called when the resource load has finished.voidRemoves the given callback from the pending set if it's still retained.voidsetRequest(Request request) Sets the current request for this target to retain, should not be called outside of Glide.Methods inherited from interface com.bumptech.glide.manager.LifecycleListener
onDestroy, onStart, onStop
-
Field Details
-
SIZE_ORIGINAL
static final int SIZE_ORIGINALIndicates that we want the resource in its original unmodified width and/or height.- See Also:
-
-
Method Details
-
onLoadStarted
A lifecycle callback that is called when a load is started.Note - This may not be called for every load, it is possible for example for loads to fail before the load starts (when the model object is null).
Note - This method may be called multiple times before any other lifecycle method is called. Loads can be paused and restarted due to lifecycle or connectivity events and each restart may cause a call here.
- Parameters:
placeholder- The placeholder drawable to optionally show, or null.
-
onLoadFailed
A mandatory lifecycle callback that is called when a load fails.Note - This may be called before
onLoadStarted(android.graphics.drawable.Drawable)if the model object is null.You must ensure that any current Drawable received in
onResourceReady(Object, Transition)is no longer used before redrawing the container (usually a View) or changing its visibility.- Parameters:
errorDrawable- The error drawable to optionally show, or null.
-
onResourceReady
The method that will be called when the resource load has finished.This may be called multiple times both within a single load and also across different loads if the
Targetobject is re-used.Within a single load this may be called multiple times for reasons that include:
- The load uses one or more thumbnails. Each time a thumbnail load completes successfully
and no higher priority load has finished, this method will be called with the thumbnail
resource. See
RequestBuilder.thumbnail(com.bumptech.glide.RequestBuilder). - The load is paused and restarted. This can happen automatically in response to
connectivity changes or the Activity / Fragment lifecycle. It can also happen if
RequestManager.pauseRequests()is called manually.
- Parameters:
resource- the loaded resource.
- The load uses one or more thumbnails. Each time a thumbnail load completes successfully
and no higher priority load has finished, this method will be called with the thumbnail
resource. See
-
onLoadCleared
A mandatory lifecycle callback that is called when a load is cancelled and its resources are freed.You must ensure that any current Drawable received in
onResourceReady(Object, Transition)is no longer used before redrawing the container (usually a View) or changing its visibility.- Parameters:
placeholder- The placeholder drawable to optionally show, or null.
-
getSize
A method to retrieve the size of this target.- Parameters:
cb- The callback that must be called when the size of the target has been determined
-
removeCallback
Removes the given callback from the pending set if it's still retained.- Parameters:
cb- The callback to remove.
-
setRequest
Sets the current request for this target to retain, should not be called outside of Glide. -
getRequest
Retrieves the current request for this target, should not be called outside of Glide.
-