Constructor and Description |
---|
RequestOptions() |
Modifier and Type | Method and Description |
---|---|
RequestOptions |
apply(RequestOptions other) |
RequestOptions |
autoClone()
|
static RequestOptions |
bitmapTransform(Transformation<Bitmap> transformation)
Returns a
RequestOptions object with transform(Transformation) set. |
RequestOptions |
centerCrop()
Applies
CenterCrop to all default types and
throws an exception if asked to transform an unknown type. |
static RequestOptions |
centerCropTransform()
Returns a
RequestOptions object with centerCrop() set. |
RequestOptions |
centerInside()
Applies
CenterInside to all default types and
throws an exception if asked to transform an unknown type. |
static RequestOptions |
centerInsideTransform()
Returns a
RequestOptions object with centerInside() set. |
RequestOptions |
circleCrop()
Applies
CircleCrop to all default types and throws an exception if asked to transform
an unknown type. |
static RequestOptions |
circleCropTransform()
Returns a
RequestOptions object with circleCrop() set. |
RequestOptions |
clone()
Returns a copy of this request builder with all of the options put so far on this builder.
|
RequestOptions |
decode(Class<?> resourceClass) |
static RequestOptions |
decodeTypeOf(Class<?> resourceClass)
Returns a
RequestOptions object with decode(Class) set. |
RequestOptions |
diskCacheStrategy(DiskCacheStrategy strategy)
Sets the
DiskCacheStrategy to use for this load. |
static RequestOptions |
diskCacheStrategyOf(DiskCacheStrategy diskCacheStrategy)
Returns a
RequestOptions object with sizeMultiplier(float) set. |
RequestOptions |
dontAnimate()
Disables resource decoders that return animated resources so any resource returned will be
static.
|
RequestOptions |
dontTransform()
Removes all applied
Transformations for all
resource classes and allows unknown resource types to be transformed without throwing an
exception. |
RequestOptions |
downsample(DownsampleStrategy strategy)
|
static RequestOptions |
downsampleOf(DownsampleStrategy strategy)
Returns a
RequestOptions object with downsample(DownsampleStrategy) set. |
RequestOptions |
encodeFormat(Bitmap.CompressFormat format)
Sets the value for key
BitmapEncoder.COMPRESSION_FORMAT . |
static RequestOptions |
encodeFormatOf(Bitmap.CompressFormat format)
Returns a
RequestOptions with encodeFormat(android.graphics.Bitmap.CompressFormat) called with the given format. |
RequestOptions |
encodeQuality(int quality)
Sets the value for key
BitmapEncoder.COMPRESSION_QUALITY . |
static RequestOptions |
encodeQualityOf(int quality)
Returns a
RequestOptions with encodeQuality(int) called with the given quality. |
RequestOptions |
error(Drawable drawable)
Sets a
Drawable to display if a load fails. |
RequestOptions |
error(int resourceId)
Sets a resource to display if a load fails.
|
static RequestOptions |
errorOf(Drawable errorDrawable)
Returns a
RequestOptions object with error(Drawable) set. |
static RequestOptions |
errorOf(int errorId)
Returns a
RequestOptions object with error(int) } set. |
RequestOptions |
fallback(Drawable drawable)
|
RequestOptions |
fallback(int resourceId)
Sets a resource to display if the model provided to
RequestBuilder.load(Object) is null . |
RequestOptions |
fitCenter()
Applies
FitCenter to all default types and
throws an exception if asked to transform an unknown type. |
static RequestOptions |
fitCenterTransform()
Returns a
RequestOptions object with fitCenter() set. |
RequestOptions |
format(DecodeFormat format)
|
static RequestOptions |
formatOf(DecodeFormat format)
Returns a
RequestOptions object with format(DecodeFormat) set. |
RequestOptions |
frame(long frameTimeMicros)
Sets the time position of the frame to extract from a video.
|
static RequestOptions |
frameOf(long frameTimeMicros)
Returns a
RequestOptions object with frame(long) set. |
DiskCacheStrategy |
getDiskCacheStrategy() |
int |
getErrorId() |
Drawable |
getErrorPlaceholder() |
Drawable |
getFallbackDrawable() |
int |
getFallbackId() |
boolean |
getOnlyRetrieveFromCache() |
Options |
getOptions() |
int |
getOverrideHeight() |
int |
getOverrideWidth() |
Drawable |
getPlaceholderDrawable() |
int |
getPlaceholderId() |
Priority |
getPriority() |
Class<?> |
getResourceClass() |
Key |
getSignature() |
float |
getSizeMultiplier() |
Resources.Theme |
getTheme() |
Map<Class<?>,Transformation<?>> |
getTransformations() |
boolean |
getUseUnlimitedSourceGeneratorsPool() |
boolean |
isLocked() |
boolean |
isMemoryCacheable() |
boolean |
isPrioritySet() |
boolean |
isTransformationAllowed() |
boolean |
isTransformationRequired() |
boolean |
isTransformationSet() |
boolean |
isValidOverride() |
RequestOptions |
lock()
Throws if any further mutations are attempted.
|
static RequestOptions |
noAnimation()
Returns a new
RequestOptions with dontAnimate()
called. |
static RequestOptions |
noTransformation()
Returns a
RequestOptions object with dontTransform() set. |
RequestOptions |
onlyRetrieveFromCache(boolean flag)
If set to true, will only load an item if found in the cache, and will not fetch from source.
|
static <T> RequestOptions |
option(Option<T> option,
T value)
|
RequestOptions |
optionalCenterCrop()
Applies
CenterCrop to all default types, and
ignores unknown types. |
RequestOptions |
optionalCenterInside()
Applies
CenterInside to all default types, and
ignores unknown types. |
RequestOptions |
optionalCircleCrop()
Applies
CircleCrop to all default types, and ignores unknown types. |
RequestOptions |
optionalFitCenter()
Applies
FitCenter to all default types, and
ignores unknown types. |
<T> RequestOptions |
optionalTransform(Class<T> resourceClass,
Transformation<T> transformation)
Applies the given
Transformation for any decoded resource of
the given type and allows unknown resource types to be ignored. |
RequestOptions |
optionalTransform(Transformation<Bitmap> transformation)
Applies the given
Transformation for
Bitmaps to the default types (Bitmap ,
BitmapDrawable , and
GifDrawable ) and ignores unknown types. |
RequestOptions |
override(int size)
Overrides the
Target 's width and height with the
given size. |
RequestOptions |
override(int width,
int height)
Overrides the
Target 's width and height with the
given values. |
static RequestOptions |
overrideOf(int size)
Returns a
RequestOptions with override(int, int) set where both the width and
height are the given size. |
static RequestOptions |
overrideOf(int width,
int height)
Returns a
RequestOptions object with override(int, int) } set. |
RequestOptions |
placeholder(Drawable drawable)
Sets an
Drawable to display while a resource is loading. |
RequestOptions |
placeholder(int resourceId)
Sets an Android resource id for a
Drawable resource to
display while a resource is loading. |
static RequestOptions |
placeholderOf(Drawable placeholder)
Returns a
RequestOptions object with placeholder(Drawable) set. |
static RequestOptions |
placeholderOf(int placeholderId)
Returns a
RequestOptions object with placeholder(int) set. |
RequestOptions |
priority(Priority priority)
Sets the priority for this load.
|
static RequestOptions |
priorityOf(Priority priority)
Returns a
RequestOptions object with priority(Priority) } set. |
<T> RequestOptions |
set(Option<T> option,
T value) |
RequestOptions |
signature(Key signature)
Sets some additional data to be mixed in to the memory and disk cache keys allowing the caller
more control over when cached data is invalidated.
|
static RequestOptions |
signatureOf(Key signature)
Returns a
RequestOptions object with signature set. |
RequestOptions |
sizeMultiplier(float sizeMultiplier)
Applies a multiplier to the
Target 's size before
loading the resource. |
static RequestOptions |
sizeMultiplierOf(float sizeMultiplier)
Returns a
RequestOptions object with sizeMultiplier(float) set. |
RequestOptions |
skipMemoryCache(boolean skip)
Allows the loaded resource to skip the memory cache.
|
static RequestOptions |
skipMemoryCacheOf(boolean skipMemoryCache)
Returns a
RequestOptions object with skipMemoryCache(boolean) set. |
RequestOptions |
theme(Resources.Theme theme)
Sets the
Resources.Theme to apply when loading Drawable s
for resource ids provided via error(int) , placeholder(int) , and
fallback(Drawable) . |
<T> RequestOptions |
transform(Class<T> resourceClass,
Transformation<T> transformation)
Applies the given
Transformation for any decoded resource of
the given type and throws if asked to transform an unknown resource type. |
RequestOptions |
transform(Transformation<Bitmap> transformation)
Applies the given
Transformation for
Bitmaps to the default types (Bitmap ,
BitmapDrawable , and
GifDrawable )
and throws an exception if asked to transform an unknown type. |
RequestOptions |
useUnlimitedSourceGeneratorsPool(boolean flag) |
public static RequestOptions sizeMultiplierOf(float sizeMultiplier)
RequestOptions
object with sizeMultiplier(float)
set.public static RequestOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy diskCacheStrategy)
RequestOptions
object with sizeMultiplier(float)
set.public static RequestOptions priorityOf(@NonNull Priority priority)
RequestOptions
object with priority(Priority)
} set.public static RequestOptions placeholderOf(@Nullable Drawable placeholder)
RequestOptions
object with placeholder(Drawable)
set.public static RequestOptions placeholderOf(int placeholderId)
RequestOptions
object with placeholder(int)
set.public static RequestOptions errorOf(@Nullable Drawable errorDrawable)
RequestOptions
object with error(Drawable)
set.public static RequestOptions errorOf(int errorId)
RequestOptions
object with error(int)
} set.public static RequestOptions skipMemoryCacheOf(boolean skipMemoryCache)
RequestOptions
object with skipMemoryCache(boolean)
set.public static RequestOptions overrideOf(int width, int height)
RequestOptions
object with override(int, int)
} set.public static RequestOptions overrideOf(int size)
RequestOptions
with override(int, int)
set where both the width and
height are the given size.public static RequestOptions signatureOf(@NonNull Key signature)
RequestOptions
object with signature
set.public static RequestOptions fitCenterTransform()
RequestOptions
object with fitCenter()
set.public static RequestOptions centerInsideTransform()
RequestOptions
object with centerInside()
set.public static RequestOptions centerCropTransform()
RequestOptions
object with centerCrop()
set.public static RequestOptions circleCropTransform()
RequestOptions
object with circleCrop()
set.public static RequestOptions bitmapTransform(@NonNull Transformation<Bitmap> transformation)
RequestOptions
object with transform(Transformation)
set.public static RequestOptions noTransformation()
RequestOptions
object with dontTransform()
set.public static <T> RequestOptions option(@NonNull Option<T> option, @NonNull T value)
public static RequestOptions decodeTypeOf(@NonNull Class<?> resourceClass)
RequestOptions
object with decode(Class)
set.public static RequestOptions formatOf(@NonNull DecodeFormat format)
RequestOptions
object with format(DecodeFormat)
set.public static RequestOptions frameOf(long frameTimeMicros)
RequestOptions
object with frame(long)
set.public static RequestOptions downsampleOf(@NonNull DownsampleStrategy strategy)
RequestOptions
object with downsample(DownsampleStrategy)
set.public static RequestOptions encodeQualityOf(int quality)
RequestOptions
with encodeQuality(int)
called with the given quality.public static RequestOptions encodeFormatOf(@NonNull Bitmap.CompressFormat format)
RequestOptions
with encodeFormat(android.graphics.Bitmap.CompressFormat)
called with the given format.public static RequestOptions noAnimation()
RequestOptions
with dontAnimate()
called.public RequestOptions sizeMultiplier(float sizeMultiplier)
Target
's size before
loading the resource. Useful for loading thumbnails or trying to avoid loading huge resources
(particularly Bitmap
s on devices with overly dense screens.sizeMultiplier
- The multiplier to apply to the
Target
's dimensions when
loading the resource.public RequestOptions useUnlimitedSourceGeneratorsPool(boolean flag)
public RequestOptions onlyRetrieveFromCache(boolean flag)
public RequestOptions diskCacheStrategy(@NonNull DiskCacheStrategy strategy)
DiskCacheStrategy
to use for this load.
Defaults to DiskCacheStrategy.AUTOMATIC
.
For most applications DiskCacheStrategy.RESOURCE
is
ideal. Applications that use the same resource multiple times in multiple sizes and are willing
to trade off some speed and disk space in return for lower bandwidth usage may want to consider
using DiskCacheStrategy.DATA
or
DiskCacheStrategy.ALL
.
strategy
- The strategy to use.public RequestOptions priority(@NonNull Priority priority)
priority
- A priority.public RequestOptions placeholder(@Nullable Drawable drawable)
Drawable
to display while a resource is loading.drawable
- The drawable to display as a placeholder.public RequestOptions placeholder(int resourceId)
Drawable
resource to
display while a resource is loading.resourceId
- The id of the resource to use as a placeholderpublic RequestOptions fallback(Drawable drawable)
Drawable
to display if the model provided to
RequestBuilder.load(Object)
is null
.
If a fallback is not set, null models will cause the error drawable to be displayed. If the error drawable is not set, the placeholder will be displayed.
drawable
- The drawable to display as a placeholder.placeholder(Drawable)
,
placeholder(int)
public RequestOptions fallback(int resourceId)
RequestBuilder.load(Object)
is null
.
If a fallback is not set, null models will cause the error drawable to be displayed. If the error drawable is not set, the placeholder will be displayed.
resourceId
- The id of the resource to use as a fallback.placeholder(Drawable)
,
placeholder(int)
public RequestOptions error(@Nullable Drawable drawable)
Drawable
to display if a load fails.drawable
- The drawable to display.public RequestOptions error(int resourceId)
resourceId
- The id of the resource to use as a placeholder.public RequestOptions theme(Resources.Theme theme)
Resources.Theme
to apply when loading Drawable
s
for resource ids provided via error(int)
, placeholder(int)
, and
fallback(Drawable)
.theme
- The theme to use when loading Drawables.public RequestOptions skipMemoryCache(boolean skip)
Note - this is not a guarantee. If a request is already pending for this resource and that request is not also skipping the memory cache, the resource will be cached in memory.
skip
- True to allow the resource to skip the memory cache.public RequestOptions override(int width, int height)
Target
's width and height with the
given values. This is useful for thumbnails, and should only be used for other cases when you
need a very specific image size.width
- The width in pixels to use to load the resource.height
- The height in pixels to use to load the resource.public RequestOptions override(int size)
Target
's width and height with the
given size.size
- The width and height to use.override(int, int)
public RequestOptions signature(@NonNull Key signature)
Note - The signature does not replace the cache key, it is purely additive.
public RequestOptions clone()
This method returns a "deep" copy in that all non-immutable arguments are copied such that changes to one builder will not affect the other builder. However, in addition to immutable arguments, the current model is not copied copied so changes to the model will affect both builders.
Even if this object was locked, the cloned object returned from this method will not be locked.
public <T> RequestOptions set(@NonNull Option<T> option, @NonNull T value)
public RequestOptions decode(@NonNull Class<?> resourceClass)
public final boolean isTransformationAllowed()
public final boolean isTransformationSet()
public final boolean isLocked()
public RequestOptions encodeFormat(@NonNull Bitmap.CompressFormat format)
BitmapEncoder.COMPRESSION_FORMAT
.public RequestOptions encodeQuality(int quality)
BitmapEncoder.COMPRESSION_QUALITY
.public RequestOptions format(@NonNull DecodeFormat format)
DecodeFormat
to use when decoding Bitmap
objects using
Downsampler
.
DecodeFormat
is a request, not a requirement. It's possible the resource will be
decoded using a decoder that cannot control the format
(MediaMetadataRetriever
for example), or that the decoder may choose to
ignore the requested format if it can't display the image (i.e. RGB_565 is requested, but the
image has alpha).
public RequestOptions frame(long frameTimeMicros)
frameTimeMicros
- The time position in microseconds of the desired frame. If negative, the
Android framework implementation return a representative frame.public RequestOptions downsample(@NonNull DownsampleStrategy strategy)
public RequestOptions optionalCenterCrop()
CenterCrop
to all default types, and
ignores unknown types.
This will override previous calls to dontTransform()
.
public RequestOptions centerCrop()
CenterCrop
to all default types and
throws an exception if asked to transform an unknown type.
this will override previous calls to dontTransform()
()}.
public RequestOptions optionalFitCenter()
FitCenter
to all default types, and
ignores unknown types.
This will override previous calls to dontTransform()
.
public RequestOptions fitCenter()
FitCenter
to all default types and
throws an exception if asked to transform an unknown type.
This will override previous calls to dontTransform()
.
public RequestOptions optionalCenterInside()
CenterInside
to all default types, and
ignores unknown types.
This will override previous calls to dontTransform()
.
public RequestOptions centerInside()
CenterInside
to all default types and
throws an exception if asked to transform an unknown type.
This will override previous calls to dontTransform()
.
public RequestOptions optionalCircleCrop()
CircleCrop
to all default types, and ignores unknown types.
This will override previous calls to dontTransform()
.
optionalTransform(Transformation)
,
circleCrop()
public RequestOptions circleCrop()
CircleCrop
to all default types and throws an exception if asked to transform
an unknown type.
This will override previous calls to dontTransform()
.
public RequestOptions transform(@NonNull Transformation<Bitmap> transformation)
Transformation
for
Bitmaps
to the default types (Bitmap
,
BitmapDrawable
, and
GifDrawable
)
and throws an exception if asked to transform an unknown type.
This will override previous calls to dontTransform()
.
transformation
- Any Transformation
for
Bitmap
s.optionalTransform(Transformation)
,
optionalTransform(Class, Transformation)
public RequestOptions optionalTransform(Transformation<Bitmap> transformation)
Transformation
for
Bitmaps
to the default types (Bitmap
,
BitmapDrawable
, and
GifDrawable
) and ignores unknown types.
This will override previous calls to dontTransform()
.
transformation
- Any Transformation
for
Bitmap
s.transform(Transformation)
,
transform(Class, Transformation)
public <T> RequestOptions optionalTransform(Class<T> resourceClass, Transformation<T> transformation)
Transformation
for any decoded resource of
the given type and allows unknown resource types to be ignored.
Users can apply different transformations for each resource class. Applying a
Transformation
for a resource type that already has a
Transformation
will override the previous call.
If any calls are made to the non-optional transform methods, then attempting to transform an unknown resource class will throw an exception. To allow unknown types, users must always call the optional version of each method.
This will override previous calls to dontTransform()
.
resourceClass
- The type of resource to transform.transformation
- The Transformation
to apply.public <T> RequestOptions transform(Class<T> resourceClass, Transformation<T> transformation)
Transformation
for any decoded resource of
the given type and throws if asked to transform an unknown resource type.
This will override previous calls to dontTransform()
.
resourceClass
- The type of resource to transform.transformation
- The Transformation
to apply.optionalTransform(Class, Transformation)
public RequestOptions dontTransform()
Transformations
for all
resource classes and allows unknown resource types to be transformed without throwing an
exception.public RequestOptions dontAnimate()
To disable transitions (fades etc) use
TransitionOptions.dontTransition()
public RequestOptions apply(RequestOptions other)
public RequestOptions lock()
Once locked, the only way to unlock is to use clone()
public RequestOptions autoClone()
lock()
except that mutations cause a clone()
operation to happen
before the mutation resulting in all methods returning a new Object and leaving the original
locked object unmodified.
Auto clone is not retained by cloned objects returned from mutations. The cloned objects are mutable and are not locked.
public final Map<Class<?>,Transformation<?>> getTransformations()
public final boolean isTransformationRequired()
public final Options getOptions()
public final Class<?> getResourceClass()
public final DiskCacheStrategy getDiskCacheStrategy()
public final Drawable getErrorPlaceholder()
public final int getErrorId()
public final int getPlaceholderId()
public final Drawable getPlaceholderDrawable()
public final int getFallbackId()
public final Drawable getFallbackDrawable()
public final Resources.Theme getTheme()
public final boolean isMemoryCacheable()
public final Key getSignature()
public final boolean isPrioritySet()
public final Priority getPriority()
public final int getOverrideWidth()
public final boolean isValidOverride()
public final int getOverrideHeight()
public final float getSizeMultiplier()
public final boolean getUseUnlimitedSourceGeneratorsPool()
public final boolean getOnlyRetrieveFromCache()