Class SingleRequest<R>
- Type Parameters:
R- The type of the resource that will be transcoded from the loaded resource.
- All Implemented Interfaces:
Request,ResourceCallback,SizeReadyCallback
-
Method Summary
Modifier and TypeMethodDescriptionvoidbegin()Starts an asynchronous load.voidclear()Cancels the current load if it is in progress, clears any resources held onto by the request and replaces the loaded resource if the load completed with the placeholder.getLock()Returns the lock to use when notifying individual requests.booleanReturns true if a resource is set, even if the request is not yet complete or the primary request has failed.booleanReturns true if the request has been cleared.booleanReturns true if the request has completed successfully.booleanbooleanReturns true if this request is running and has not completed or failed.static <R> SingleRequest<R>obtain(Context context, GlideContext glideContext, Object requestLock, Object model, Class<R> transcodeClass, BaseRequestOptions<?> requestOptions, int overrideWidth, int overrideHeight, Priority priority, Target<R> target, RequestListener<R> targetListener, List<RequestListener<R>> requestListeners, RequestCoordinator requestCoordinator, Engine engine, TransitionFactory<? super R> animationFactory, Executor callbackExecutor) voidA callback method that should never be invoked directly.voidonResourceReady(Resource<?> resource, DataSource dataSource, boolean isLoadedFromAlternateCacheKey) A callback method that should never be invoked directly.voidonSizeReady(int width, int height) A callback method that should never be invoked directly.voidpause()Similar toRequest.clear()for in progress requests (or portions of a request), but does nothing if the request is already complete.toString()
-
Method Details
-
obtain
public static <R> SingleRequest<R> obtain(Context context, GlideContext glideContext, Object requestLock, Object model, Class<R> transcodeClass, BaseRequestOptions<?> requestOptions, int overrideWidth, int overrideHeight, Priority priority, Target<R> target, RequestListener<R> targetListener, @Nullable List<RequestListener<R>> requestListeners, RequestCoordinator requestCoordinator, Engine engine, TransitionFactory<? super R> animationFactory, Executor callbackExecutor) -
begin
public void begin()Description copied from interface:RequestStarts an asynchronous load. -
clear
public void clear()Cancels the current load if it is in progress, clears any resources held onto by the request and replaces the loaded resource if the load completed with the placeholder.Cleared requests can be restarted with a subsequent call to
begin() -
pause
public void pause()Description copied from interface:RequestSimilar toRequest.clear()for in progress requests (or portions of a request), but does nothing if the request is already complete.Unlike
Request.clear(), this method allows implementations to act differently on subparts of a request. For example if a Request has both a thumbnail and a primary request and the thumbnail portion of the request is complete, this method allows only the primary portion of the request to be paused without clearing the previously completed thumbnail portion. -
isRunning
public boolean isRunning()Description copied from interface:RequestReturns true if this request is running and has not completed or failed. -
isComplete
public boolean isComplete()Description copied from interface:RequestReturns true if the request has completed successfully.- Specified by:
isCompletein interfaceRequest
-
isCleared
public boolean isCleared()Description copied from interface:RequestReturns true if the request has been cleared. -
isAnyResourceSet
public boolean isAnyResourceSet()Description copied from interface:RequestReturns true if a resource is set, even if the request is not yet complete or the primary request has failed.- Specified by:
isAnyResourceSetin interfaceRequest
-
onSizeReady
public void onSizeReady(int width, int height) A callback method that should never be invoked directly.- Specified by:
onSizeReadyin interfaceSizeReadyCallback- Parameters:
width- The width in pixels of the target, orTarget.SIZE_ORIGINALto indicate that we want the resource at its original width.height- The height in pixels of the target, orTarget.SIZE_ORIGINALto indicate that we want the resource at its original height.
-
onResourceReady
public void onResourceReady(Resource<?> resource, DataSource dataSource, boolean isLoadedFromAlternateCacheKey) A callback method that should never be invoked directly.- Specified by:
onResourceReadyin interfaceResourceCallback- Parameters:
resource- The loaded resource.
-
onLoadFailed
A callback method that should never be invoked directly.- Specified by:
onLoadFailedin interfaceResourceCallback- Parameters:
e- a non-nullGlideException.
-
getLock
Description copied from interface:ResourceCallbackReturns the lock to use when notifying individual requests.- Specified by:
getLockin interfaceResourceCallback
-
isEquivalentTo
Description copied from interface:RequestReturnstrueif thisRequestis equivalent to the givenRequest(has all of the same options and sizes).This method is identical to
Object.equals(Object)except that it's specific toRequestsubclasses. We do not useObject.equals(Object)directly because we trackRequests in collections likeSetand it's perfectly legitimate to have two differentRequestobjects for two differentTargets (for example). Using a similar but different method let's us selectively compareRequestobjects to each other when it's useful in specific scenarios.- Specified by:
isEquivalentToin interfaceRequest
-
toString
-