T - The type of the data to load.R - The type of the resource that will be loaded.public class RequestFutureTarget<T,R> extends Object implements FutureTarget<R>, Runnable
Future implementation for Glide that can be used to load resources in a blocking
manner on background threads.
Note - Unlike most targets, RequestFutureTargets can be used once and only once. Attempting to reuse a RequestFutureTarget will probably result in undesirable behavior or exceptions. Instead of reusing objects of this class, the pattern should be:
RequestFutureTarget target = Glide.load("")...
Object resource = target.get();
// Do something with resource, and when finished:
Glide.clear(target);
The Glide.clear(FutureTarget) call will make sure any resources used are recycled.
SIZE_ORIGINAL| Constructor and Description |
|---|
RequestFutureTarget(Handler mainHandler,
int width,
int height)
Constructor for a RequestFutureTarget.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
void |
clear()
Can be safely called from either the main thread or a background thread to cleanup the resources used by this
target.
|
R |
get() |
R |
get(long time,
TimeUnit timeUnit) |
Request |
getRequest()
Retrieves the current request for this target, should not be called outside of Glide.
|
void |
getSize(SizeReadyCallback cb)
A callback that should never be invoked directly.
|
boolean |
isCancelled() |
boolean |
isDone() |
void |
onDestroy()
Callback for when
Fragment.onDestroy()} or Activity.onDestroy() is
called. |
void |
onLoadCleared(Drawable placeholder)
A callback that should never be invoked directly.
|
void |
onLoadFailed(Exception e,
Drawable errorDrawable)
A callback that should never be invoked directly.
|
void |
onLoadStarted(Drawable placeholder)
A callback that should never be invoked directly.
|
void |
onResourceReady(R resource,
GlideAnimation<? super R> glideAnimation)
A callback that should never be invoked directly.
|
void |
onStart()
Callback for when
Fragment.onStart()} or Activity.onStart() is called. |
void |
onStop()
Callback for when
Fragment.onStop()} or Activity.onStop()} is called. |
void |
run()
A callback that should never be invoked directly.
|
void |
setRequest(Request request)
Sets the current request for this target to retain, should not be called outside of Glide.
|
public RequestFutureTarget(Handler mainHandler, int width, int height)
public boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
isCancelled in interface Future<R>public R get() throws InterruptedException, ExecutionException
get in interface Future<R>InterruptedExceptionExecutionExceptionpublic R get(long time, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException
get in interface Future<R>InterruptedExceptionExecutionExceptionTimeoutExceptionpublic void getSize(SizeReadyCallback cb)
public void setRequest(Request request)
TargetsetRequest in interface Target<R>public Request getRequest()
TargetgetRequest in interface Target<R>public void onLoadCleared(Drawable placeholder)
onLoadCleared in interface Target<R>placeholder - The placeholder drawable to optionally show, or null.public void onLoadStarted(Drawable placeholder)
onLoadStarted in interface Target<R>placeholder - The placeholder drawable to optionally show, or null.public void onLoadFailed(Exception e, Drawable errorDrawable)
onLoadFailed in interface Target<R>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.public void onResourceReady(R resource, GlideAnimation<? super R> glideAnimation)
onResourceReady in interface Target<R>resource - the loaded resource.public void run()
public void clear()
clear in interface FutureTarget<R>public void onStart()
LifecycleListenerFragment.onStart()} or Activity.onStart() is called.onStart in interface LifecycleListenerpublic void onStop()
LifecycleListenerFragment.onStop()} or Activity.onStop()} is called.onStop in interface LifecycleListenerpublic void onDestroy()
LifecycleListenerFragment.onDestroy()} or Activity.onDestroy() is
called.onDestroy in interface LifecycleListener