com.bumptech.glide.request.target
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, DrawableImageViewTarget, GlideDrawableImageViewTarget, ImageViewTarget, NotificationTarget, PreloadTarget, RequestFutureTarget, SimpleTarget, ViewTarget

public interface Target<R>
extends LifecycleListener

An interface that Glide can load a resource into and notify of relevant lifecycle events during a load.

The lifecycle events in this class are as follows:

The typical lifecycle is onLoadStarted -> onResourceReady or onLoadFailed -> 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
static int SIZE_ORIGINAL
          Indicates that we want the resource in its original unmodified width and/or height.
 
Method Summary
 Request getRequest()
          Retrieves the current request for this target, should not be called outside of Glide.
 void getSize(SizeReadyCallback cb)
          A method to retrieve the size of this target.
 void onLoadCleared(Drawable placeholder)
          A lifecycle callback that is called when a load is cancelled and its resources are freed.
 void onLoadFailed(Exception e, Drawable errorDrawable)
          A lifecycle callback that is called when a load fails.
 void onLoadStarted(Drawable placeholder)
          A lifecycle callback that is called when a load is started.
 void onResourceReady(R resource, GlideAnimation<? super R> glideAnimation)
          The method that will be called when the resource load has finished.
 void setRequest(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 Detail

SIZE_ORIGINAL

static final int SIZE_ORIGINAL
Indicates that we want the resource in its original unmodified width and/or height.

See Also:
Constant Field Values
Method Detail

onLoadStarted

void onLoadStarted(Drawable placeholder)
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

void onLoadFailed(Exception e,
                  Drawable errorDrawable)
A 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.

Parameters:
e - The exception causing the load to fail, or null if no exception occurred (usually because a decoder simply returned null).
errorDrawable - The error drawable to optionally show, or null.

onResourceReady

void onResourceReady(R resource,
                     GlideAnimation<? super R> glideAnimation)
The method that will be called when the resource load has finished.

Parameters:
resource - the loaded resource.

onLoadCleared

void onLoadCleared(Drawable placeholder)
A lifecycle callback that is called when a load is cancelled and its resources are freed.

Parameters:
placeholder - The placeholder drawable to optionally show, or null.

getSize

void getSize(SizeReadyCallback cb)
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

setRequest

void setRequest(Request request)
Sets the current request for this target to retain, should not be called outside of Glide.


getRequest

Request getRequest()
Retrieves the current request for this target, should not be called outside of Glide.