submitAndExecute
Submits the provided request, performs the provided action
and returns a that can be used to cancel the request or monitor its status.
Cancellation is best effort and may result in some resources not being returned back to Glide's pool. In particular, if the request is cancelled after the resource is loaded by Glide, but before action
is run on executor
, the resource will not be returned. We have the unfortunate choice between unsafely returning resources to the pool immediately when cancel is called while they may still be in use via or occasionally failing to return resources to the pool. Because failing to return resources to the pool is inefficient, but safe, that's the route we've chosen. A more sophisticated implementation may allow us to avoid the resource inefficiency.
If you do not need to interact with resource, use preload. preload
is more efficient because it knows that the resource is never used and can always clear the resource immediately on cancellation, unlike this method.
An example usage:
ListenableFuture<Void> future =
submitAndExecute(
requestManager,
requestBuilder,
(bitmap) -> doSomethingWithBitmap(bitmap),
backgroundExecutor);
;
Parameters
The type of resource that will be loaded (Bitmap, Drawable, etc).