RequestFutureTarget

open class RequestFutureTarget<R> : FutureTarget<R> , RequestListener<R>

A java.util.concurrent.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:


FutureTarget<File> target = null;
RequestManager requestManager = Glide.with(context);
try {
  target = requestManager
     .downloadOnly()
     .load(model)
     .submit();
  File downloadedFile = target.get();
  // ... do something with the file (usually throws IOException)
} catch (ExecutionException | InterruptedException | IOException e) {
  // ... bug reporting or recovery
} finally {
  // make sure to cancel pending operations and free resources
  if (target != null) {
    target.cancel(true); // mayInterruptIfRunning
  }
}
The cancel call will cancel pending operations and make sure that any resources used are recycled.

Parameters

<R>

The type of the resource that will be loaded.

Constructors

Link copied to clipboard
open fun RequestFutureTarget(width: Int, height: Int)
Constructor for a RequestFutureTarget.

Functions

Link copied to clipboard
open fun cancel(mayInterruptIfRunning: Boolean): Boolean
Link copied to clipboard
open fun get(): R
open fun get(time: Long, timeUnit: TimeUnit): R
Link copied to clipboard
open fun getSize(cb: SizeReadyCallback)
A callback that should never be invoked directly.
Link copied to clipboard
abstract fun isCancelled(): Boolean
Link copied to clipboard
open fun isDone(): Boolean
Link copied to clipboard
open fun onDestroy()
Callback for when onDestroy} or onDestroy is called.
Link copied to clipboard
open fun onLoadCleared(placeholder: Drawable)
A callback that should never be invoked directly.
Link copied to clipboard
open fun onLoadFailed(errorDrawable: Drawable)
A callback that should never be invoked directly.
open fun onLoadFailed(    e: GlideException,     model: Any,     target: Target<R>,     isFirstResource: Boolean): Boolean
Called when an exception occurs during a load, immediately before onLoadFailed.
Link copied to clipboard
open fun onLoadStarted(placeholder: Drawable)
A callback that should never be invoked directly.
Link copied to clipboard
open fun onResourceReady(resource: R, transition: Transition<out Any>)
A callback that should never be invoked directly.
open fun onResourceReady(    resource: R,     model: Any,     target: Target<R>,     dataSource: DataSource,     isFirstResource: Boolean): Boolean
Called when a load completes successfully, immediately before onResourceReady.
Link copied to clipboard
open fun onStart()
Callback for when onStart} or onStart is called.
Link copied to clipboard
open fun onStop()
Callback for when onStop} or onStop} is called.
Link copied to clipboard
open fun removeCallback(cb: SizeReadyCallback)
Removes the given callback from the pending set if it's still retained.
Link copied to clipboard
open fun toString(): String

Properties

Link copied to clipboard
open val isCancelled: Boolean
Link copied to clipboard
open var request: Request
Link copied to clipboard
val SIZE_ORIGINAL: Int
Indicates that we want the resource in its original unmodified width and/or height.