RequestFutureTarget
open class RequestFutureTarget<R> : FutureTarget<R> , RequestListener<R>
Content copied to clipboard
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
}
}
Content copied to clipboard
Parameters
<R>
The type of the resource that will be loaded.
Constructors
Functions
Link copied to clipboard
A callback that should never be invoked directly.
Link copied to clipboard
Link copied to clipboard
A callback that should never be invoked directly.
Link copied to clipboard
A callback that should never be invoked directly.
open fun onLoadFailed( e: GlideException, model: Any, target: Target<R>, isFirstResource: Boolean): Boolean
Content copied to clipboard
Called when an exception occurs during a load, immediately before onLoadFailed.
Link copied to clipboard
A callback that should never be invoked directly.
Link copied to clipboard
A callback that should never be invoked directly.
open fun onResourceReady( resource: R, model: Any, target: Target<R>, dataSource: DataSource, isFirstResource: Boolean): Boolean
Content copied to clipboard
Called when a load completes successfully, immediately before onResourceReady.
Link copied to clipboard
Removes the given callback from the pending set if it's still retained.