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, DownsampleStrategy.CENTER_INSIDE to
image 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 |
disallowHardwareConfig()
Disables the use of
Bitmap.Config.HARDWARE in Downsampler to
avoid errors caused by inspecting Bitmap pixels, drawing with hardware support disabled,
drawing to Canvas s backed by Bitmap s etc. |
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. |
boolean |
equals(Object o) |
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 and to all default types, DownsampleStrategy.FIT_CENTER to
image 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() |
int |
hashCode() |
protected boolean |
isAutoCloneEnabled() |
boolean |
isLocked() |
boolean |
isMemoryCacheable() |
boolean |
isPrioritySet() |
boolean |
isScaleOnlyOrNoTransform() |
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,
DownsampleStrategy.CENTER_INSIDE to image types, and ignores unknown types. |
RequestOptions |
optionalCircleCrop()
Applies
CircleCrop to all default types, and ignores unknown types. |
RequestOptions |
optionalFitCenter()
Applies
FitCenter and to all default types, DownsampleStrategy.FIT_CENTER to
image 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) . |
RequestOptions |
timeout(int timeoutMs)
Sets the read and write timeout for the http requests used to load the image.
|
static RequestOptions |
timeoutOf(int timeout)
Returns a
RequestOptions object with timeout(int) set. |
<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 |
transforms(Transformation<Bitmap>... transformations)
Applies the given
Transformation s in the given order 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 timeoutOf(int timeout)
RequestOptions
object with timeout(int)
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 frame(long frameTimeMicros)
This is a component option specific to VideoBitmapDecoder
. If the default video
decoder is replaced or skipped because of your configuration, this option may be ignored.
frameTimeMicros
- The time position in microseconds of the desired frame. If negative, the
Android framework implementation return a representative frame.VideoBitmapDecoder.TARGET_FRAME
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).
This is a component option specific to Downsampler
. If the defautlt Bitmap decoder
is replaced or skipped because of your configuration, this option may be ignored.
Downsampler.DECODE_FORMAT
public RequestOptions disallowHardwareConfig()
Bitmap.Config.HARDWARE
in Downsampler
to
avoid errors caused by inspecting Bitmap pixels, drawing with hardware support disabled,
drawing to Canvas
s backed by Bitmap
s etc.
It's almost never safe to set Downsampler.ALLOW_HARDWARE_CONFIG
to true
so
we only provide a way to disable hardware configs entirely. If no option is set for
Downsampler.ALLOW_HARDWARE_CONFIG
, Glide will set the value per request based on
whether or not a Transformation
is applied and if one is, the type of
Transformation
applied. Built in transformations like FitCenter
and
DownsampleStrategy.CenterOutside
can safely use
Bitmap.Config.HARDWARE
because they can be entirely replaced by
scaling within Downsampler
. Transformation
s like circleCrop()
that
can't be replicated by Downsampler
cannot use Bitmap.Config#HARDWARE
because
Bitmap.Config.HARDWARE
cannot be drawn to
Canvas
s, which is required by most Transformation
s.
public RequestOptions downsample(@NonNull DownsampleStrategy strategy)
DownsampleStrategy
to use when decoding Bitmaps
using
Downsampler
.
This is a component option specific to Downsampler
. If the defautlt Bitmap decoder
is replaced or skipped because of your configuration, this option may be ignored.
public RequestOptions timeout(int timeoutMs)
This is a component option specific to Glide's default networking library and
HttpGlideUrlLoader
. If you use any other
networking library including Glide's Volley or OkHttp integration libraries, this option will
be ignored.
timeoutMs
- The read and write timeout in milliseconds.HttpGlideUrlLoader.TIMEOUT
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
and to all default types, DownsampleStrategy.FIT_CENTER
to
image types, and ignores unknown types.
This will override previous calls to dontTransform()
and previous calls to
downsample(DownsampleStrategy)
.
public RequestOptions fitCenter()
FitCenter
and to all default types, DownsampleStrategy.FIT_CENTER
to
image types, and throws an exception if asked to transform an unknown
type.
This will override previous calls to dontTransform()
and previous calls to
downsample(DownsampleStrategy)
.
public RequestOptions optionalCenterInside()
CenterInside
to all default types,
DownsampleStrategy.CENTER_INSIDE
to image types, and ignores unknown types.
This will override previous calls to dontTransform()
and previous calls to
downsample(DownsampleStrategy)
.
public RequestOptions centerInside()
CenterInside
to all default types, DownsampleStrategy.CENTER_INSIDE
to
image types and throws an exception if asked to transform an unknown type.
This will override previous calls to dontTransform()
and previous calls to
downsample(DownsampleStrategy)
.
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 transforms(@NonNull Transformation<Bitmap>... transformations)
Transformation
s in the given order 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()
.
transformations
- One or more Transformation
s 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.
protected boolean isAutoCloneEnabled()
@NonNull public final Map<Class<?>,Transformation<?>> getTransformations()
public final boolean isTransformationRequired()
@NonNull public final DiskCacheStrategy getDiskCacheStrategy()
public final int getErrorId()
public final int getPlaceholderId()
public final int getFallbackId()
@Nullable public final Resources.Theme getTheme()
public final boolean isMemoryCacheable()
public final boolean isPrioritySet()
public final int getOverrideWidth()
public final boolean isValidOverride()
public final int getOverrideHeight()
public final float getSizeMultiplier()
public boolean isScaleOnlyOrNoTransform()
public final boolean getUseUnlimitedSourceGeneratorsPool()
public final boolean getOnlyRetrieveFromCache()