R
- The type of the resource that will be transcoded from the loaded resource.public final class SingleRequest<R> extends java.lang.Object implements Request, SizeReadyCallback, ResourceCallback
Modifier and Type | Method and Description |
---|---|
void |
begin()
Starts an asynchronous load.
|
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.
|
java.lang.Object |
getLock()
Returns the lock to use when notifying individual requests.
|
boolean |
isAnyResourceSet()
Returns true if a resource is set, even if the request is not yet complete or the primary
request has failed.
|
boolean |
isCleared()
Returns true if the request has been cleared.
|
boolean |
isComplete()
Returns true if the request has completed successfully.
|
boolean |
isEquivalentTo(Request o)
|
boolean |
isRunning()
Returns true if this request is running and has not completed or failed.
|
static <R> SingleRequest<R> |
obtain(android.content.Context context,
GlideContext glideContext,
java.lang.Object requestLock,
java.lang.Object model,
java.lang.Class<R> transcodeClass,
BaseRequestOptions<?> requestOptions,
int overrideWidth,
int overrideHeight,
Priority priority,
Target<R> target,
RequestListener<R> targetListener,
java.util.List<RequestListener<R>> requestListeners,
RequestCoordinator requestCoordinator,
Engine engine,
TransitionFactory<? super R> animationFactory,
java.util.concurrent.Executor callbackExecutor) |
void |
onLoadFailed(GlideException e)
A callback method that should never be invoked directly.
|
void |
onResourceReady(Resource<?> resource,
DataSource dataSource)
A callback method that should never be invoked directly.
|
void |
onSizeReady(int width,
int height)
A callback method that should never be invoked directly.
|
void |
pause()
Similar to
Request.clear() for in progress requests (or portions of a request), but does nothing
if the request is already complete. |
public static <R> SingleRequest<R> obtain(android.content.Context context, GlideContext glideContext, java.lang.Object requestLock, java.lang.Object model, java.lang.Class<R> transcodeClass, BaseRequestOptions<?> requestOptions, int overrideWidth, int overrideHeight, Priority priority, Target<R> target, RequestListener<R> targetListener, @Nullable java.util.List<RequestListener<R>> requestListeners, RequestCoordinator requestCoordinator, Engine engine, TransitionFactory<? super R> animationFactory, java.util.concurrent.Executor callbackExecutor)
public void begin()
Request
public void clear()
Cleared requests can be restarted with a subsequent call to begin()
public void pause()
Request
Request.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.
public boolean isRunning()
Request
public boolean isComplete()
Request
isComplete
in interface Request
public boolean isCleared()
Request
public boolean isAnyResourceSet()
Request
isAnyResourceSet
in interface Request
public void onSizeReady(int width, int height)
onSizeReady
in interface SizeReadyCallback
width
- The width in pixels of the target, or Target.SIZE_ORIGINAL
to indicate
that we want the resource at its original width.height
- The height in pixels of the target, or Target.SIZE_ORIGINAL
to indicate
that we want the resource at its original height.public void onResourceReady(Resource<?> resource, DataSource dataSource)
onResourceReady
in interface ResourceCallback
resource
- The loaded resource.public void onLoadFailed(GlideException e)
onLoadFailed
in interface ResourceCallback
e
- a non-null GlideException
.public java.lang.Object getLock()
ResourceCallback
getLock
in interface ResourceCallback
public boolean isEquivalentTo(Request o)
Request
true
if this Request
is equivalent to the given Request
(has
all of the same options and sizes).
This method is identical to Object.equals(Object)
except that it's specific to
Request
subclasses. We do not use Object.equals(Object)
directly because we
track Request
s in collections like Set
and it's perfectly legitimate
to have two different Request
objects for two different Target
s (for example). Using a similar but different method
let's us selectively compare Request
objects to each other when it's useful in specific
scenarios.
isEquivalentTo
in interface Request