-
- All Implemented Interfaces:
-
java.lang.Cloneable
public abstract class BaseRequestOptions<T extends BaseRequestOptions<T>> implements Cloneable
A base object to allow method sharing between RequestOptions and .
This class is not meant for general use and may change at any time.
-
-
Field Summary
Fields Modifier and Type Field Description private floatsizeMultiplierprivate DiskCacheStrategydiskCacheStrategyprivate Prioritypriorityprivate DrawableerrorPlaceholderprivate interrorIdprivate DrawableplaceholderDrawableprivate intplaceholderIdprivate intoverrideHeightprivate intoverrideWidthprivate Keysignatureprivate booleanisTransformationRequiredprivate booleanisTransformationAllowedprivate DrawablefallbackDrawableprivate intfallbackIdprivate Optionsoptionsprivate Map<Class<out Object>, Transformation<out Object>>transformationsprivate Class<out Object>resourceClassprivate booleanisLockedprivate Resources.Themethemeprivate booleanuseUnlimitedSourceGeneratorsPoolprivate booleanonlyRetrieveFromCacheprivate booleanuseAnimationPool
-
Method Summary
Modifier and Type Method Description final floatgetSizeMultiplier()final DiskCacheStrategygetDiskCacheStrategy()final PrioritygetPriority()final DrawablegetErrorPlaceholder()final intgetErrorId()final DrawablegetPlaceholderDrawable()final intgetPlaceholderId()final intgetOverrideHeight()final intgetOverrideWidth()final KeygetSignature()final booleanisTransformationRequired()final booleanisTransformationAllowed()final DrawablegetFallbackDrawable()final intgetFallbackId()final OptionsgetOptions()final Map<Class<out Object>, Transformation<out Object>>getTransformations()final Class<out Object>getResourceClass()final booleanisLocked()final Resources.ThemegetTheme()final booleangetUseUnlimitedSourceGeneratorsPool()final booleangetOnlyRetrieveFromCache()final booleangetUseAnimationPool()TsizeMultiplier(@FloatRange(from = 0, to = 1) float sizeMultiplier)Applies a multiplier to the com.mobwith.imgmodule.request.target.Target's size beforeloading the resource. TuseUnlimitedSourceGeneratorsPool(boolean flag)If set to {@code true}, uses a cached unlimited java.util.concurrent.Executor to runthe request.TuseAnimationPool(boolean flag)If set to {@code true}, uses a special java.util.concurrent.Executor that is usedexclusively for decoding frames of animated resources, like GIFs.TonlyRetrieveFromCache(boolean flag)If set to true, will only load an item if found in the cache, and will not fetch from source. TdiskCacheStrategy(@NonNull() DiskCacheStrategy strategy)Sets the DiskCacheStrategy to use for this load. Tpriority(@NonNull() Priority priority)Sets the priority for this load. Tplaceholder(@Nullable() Drawable drawable)Sets an Drawable to display while a resource is loading. Tplaceholder(@DrawableRes() int resourceId)Sets an Android resource id for a Drawable resource to display while a resource isloading. Tfallback(@Nullable() Drawable drawable)Sets an Drawable to display if the model provided to is {@code null}.Tfallback(@DrawableRes() int resourceId)Sets a resource to display if the model provided to is {@code null}.Terror(@Nullable() Drawable drawable)Sets a Drawable to display if a load fails. Terror(@DrawableRes() int resourceId)Sets a resource to display if a load fails. Ttheme(@Nullable() Resources.Theme theme)Sets the Resources.Theme to apply when loading Drawablesfor resource ids provided via error, placeholder, and . TskipMemoryCache(boolean skip)Allows the loaded resource to skip the memory cache. Toverride(int width, int height)Overrides the com.mobwith.imgmodule.request.target.Target's width and height with thegiven values. Toverride(int size)Overrides the com.mobwith.imgmodule.request.target.Target's width and height with thegiven size. Tsignature(@NonNull() Key signature)Sets some additional data to be mixed in to the memory and disk cache keys allowing the callermore control over when cached data is invalidated. Tclone()Returns a copy of this request builder with all of the options put so far on this builder. <Y> Tset(@NonNull() Option<Y> option, @NonNull() Y value)Tdecode(@NonNull() Class<out Object> resourceClass)final booleanisTransformationSet()TencodeFormat(@NonNull() Bitmap.CompressFormat format)Sets the value for key . TencodeQuality(@IntRange(from = 0, to = 100) int quality)Sets the value for key COMPRESSION_QUALITY. Tframe(@IntRange(from = 0) long frameTimeMicros)Sets the time position of the frame to extract from a video. Tformat(@NonNull() DecodeFormat format)Sets the DecodeFormat to use when decoding Bitmap objects using and ImageModule default GIF decoders. TdisallowHardwareConfig()Disables the use of HARDWARE in Downsampler toavoid errors caused by inspecting Bitmap pixels, drawing with hardware support disabled,drawing to android.graphics.Canvass backed by Bitmaps etc. Tdownsample(@NonNull() DownsampleStrategy strategy)Sets the DownsampleStrategy to use when decoding Bitmaps using . Ttimeout(@IntRange(from = 0) int timeoutMs)Sets the read and write timeout for the http requests used to load the image. ToptionalCenterCrop()Applies com.mobwith.imgmodule.load.resource.bitmap.CenterCrop to all default types, andignores unknown types. TcenterCrop()Applies CenterCrop to all default types and throws an exception if asked to transforman unknown type. ToptionalFitCenter()Applies FitCenter and to all default types, FIT_CENTER toimage types, and ignores unknown types. TfitCenter()Applies FitCenter and to all default types, FIT_CENTER toimage types, and throws an exception if asked to transform an unknown type. ToptionalCenterInside()Applies com.mobwith.imgmodule.load.resource.bitmap.CenterInside to all default types, CENTER_INSIDE to image types, and ignores unknown types. TcenterInside()Applies CenterInside to all default types, CENTER_INSIDE toimage types and throws an exception if asked to transform an unknown type. ToptionalCircleCrop()Applies CircleCrop to all default types, and ignores unknown types. TcircleCrop()Applies CircleCrop to all default types and throws an exception if asked to transforman unknown type. Ttransform(@NonNull() Transformation<Bitmap> transformation)Applies the given Transformation for Bitmaps to the default types(Bitmap, BitmapDrawable, and ) and throws an exception if asked totransform an unknown type. Ttransform(@NonNull() Array<Transformation<Bitmap>> transformations)Applies the given Transformations in the given order for Bitmaps to thedefault types (Bitmap, BitmapDrawable, and ) and throws an exception if asked totransform an unknown type. Ttransforms(@NonNull() Array<Transformation<Bitmap>> transformations)Applies the given Transformations in the given order for Bitmaps to thedefault types (Bitmap, BitmapDrawable, and ) and throws an exception if asked totransform an unknown type. ToptionalTransform(@NonNull() Transformation<Bitmap> transformation)Applies the given Transformation for Bitmaps to the default types(Bitmap, BitmapDrawable, and ) and ignores unknown types. <Y> ToptionalTransform(@NonNull() Class<Y> resourceClass, @NonNull() Transformation<Y> transformation)Applies the given Transformation for any decoded resource of the given type and allowsunknown resource types to be ignored. <Y> Ttransform(@NonNull() Class<Y> resourceClass, @NonNull() Transformation<Y> transformation)Applies the given Transformation for any decoded resource of the given type and throwsif asked to transform an unknown resource type. TdontTransform()Removes all applied Transformations for all resource classes and allowsunknown resource types to be transformed without throwing an exception. TdontAnimate()Disables resource decoders that return animated resources so any resource returned will bestatic. Tapply(@NonNull() BaseRequestOptions<out Object> o)Updates this options set with any options that are explicitly set in the given {@code T}objectand returns this object if autoClone is disabled or a new{@code T}object if is enabled.booleanequals(Object o)inthashCode()Tlock()Throws if any further mutations are attempted. TautoClone()Similar to lock except that mutations cause a clone operation to happenbefore the mutation resulting in all methods returning a new Object and leaving the originallocked object unmodified. final booleanisDiskCacheStrategySet()final booleanisSkipMemoryCacheSet()final booleanisMemoryCacheable()final booleanisPrioritySet()final booleanisValidOverride()-
-
Method Detail
-
getSizeMultiplier
final float getSizeMultiplier()
-
getDiskCacheStrategy
@NonNull() final DiskCacheStrategy getDiskCacheStrategy()
-
getPriority
@NonNull() final Priority getPriority()
-
getErrorPlaceholder
@Nullable() final Drawable getErrorPlaceholder()
-
getErrorId
final int getErrorId()
-
getPlaceholderDrawable
@Nullable() final Drawable getPlaceholderDrawable()
-
getPlaceholderId
final int getPlaceholderId()
-
getOverrideHeight
final int getOverrideHeight()
-
getOverrideWidth
final int getOverrideWidth()
-
getSignature
@NonNull() final Key getSignature()
-
isTransformationRequired
final boolean isTransformationRequired()
-
isTransformationAllowed
final boolean isTransformationAllowed()
-
getFallbackDrawable
@Nullable() final Drawable getFallbackDrawable()
-
getFallbackId
final int getFallbackId()
-
getOptions
@NonNull() final Options getOptions()
-
getTransformations
@NonNull() final Map<Class<out Object>, Transformation<out Object>> getTransformations()
-
getResourceClass
@NonNull() final Class<out Object> getResourceClass()
-
isLocked
final boolean isLocked()
-
getTheme
@Nullable() final Resources.Theme getTheme()
-
getUseUnlimitedSourceGeneratorsPool
final boolean getUseUnlimitedSourceGeneratorsPool()
-
getOnlyRetrieveFromCache
final boolean getOnlyRetrieveFromCache()
-
getUseAnimationPool
final boolean getUseAnimationPool()
-
sizeMultiplier
@NonNull()@CheckResult() T sizeMultiplier(@FloatRange(from = 0, to = 1) float sizeMultiplier)
Applies a multiplier to the com.mobwith.imgmodule.request.target.Target's size beforeloading the resource. Useful for loading thumbnails or trying to avoid loading huge resources(particularly Bitmaps on devices with overly dense screens.
- Parameters:
sizeMultiplier- The multiplier to apply to the 's dimensions when loading the resource.
-
useUnlimitedSourceGeneratorsPool
@NonNull()@CheckResult() T useUnlimitedSourceGeneratorsPool(boolean flag)
If set to
{@code true}, uses a cached unlimited java.util.concurrent.Executor to runthe request.This method should ONLY be used when a ImageModule load is started recursively on one ofImageModule threads as part of another request. Using this method in other scenarios can lead toexcessive memory usage and OOMs and/or a significant decrease in performance across anapplication.
If both this method and useAnimationPool are set, this method will bepreferred and useAnimationPool will be ignored.
-
useAnimationPool
@NonNull()@CheckResult() T useAnimationPool(boolean flag)
If set to
{@code true}, uses a special java.util.concurrent.Executor that is usedexclusively for decoding frames of animated resources, like GIFs.The animation executor disallows network operations and must not be used for loads that mayload remote data. The animation executor has fewer threads available to it than ImageModule normalexecutors and is only useful as a way of avoiding blocking on longer and more expensive readsfor critical requests like those in an animating GIF.
If both useUnlimitedSourceGeneratorsPool and this method are set, will be preferred and this method will be ignored.
-
onlyRetrieveFromCache
@NonNull()@CheckResult() T onlyRetrieveFromCache(boolean flag)
If set to true, will only load an item if found in the cache, and will not fetch from source.
-
diskCacheStrategy
@NonNull()@CheckResult() T diskCacheStrategy(@NonNull() DiskCacheStrategy strategy)
Sets the DiskCacheStrategy to use for this load.
Defaults to AUTOMATIC.
For most applications RESOURCE is ideal. Applications that use thesame resource multiple times in multiple sizes and are willing to trade off some speed and diskspace in return for lower bandwidth usage may want to consider using or ALL.
- Parameters:
strategy- The strategy to use.
-
priority
@NonNull()@CheckResult() T priority(@NonNull() Priority priority)
Sets the priority for this load.
- Parameters:
priority- A priority.
-
placeholder
@NonNull()@CheckResult() T placeholder(@Nullable() Drawable drawable)
Sets an Drawable to display while a resource is loading.
Replaces any previous calls to this method or placeholder.
- Parameters:
drawable- The drawable to display as a placeholder.
-
placeholder
@NonNull()@CheckResult() T placeholder(@DrawableRes() int resourceId)
Sets an Android resource id for a Drawable resource to display while a resource isloading.
Replaces any previous calls to this method or placeholder
- Parameters:
resourceId- The id of the resource to use as a placeholder
-
fallback
@NonNull()@CheckResult() T fallback(@Nullable() Drawable drawable)
Sets an Drawable to display if the model provided to is
{@code null}.If a fallback is not set, null models will cause the error drawable to be displayed. If theerror drawable is not set, the placeholder will be displayed.
Replaces any previous calls to this method or fallback.
- Parameters:
drawable- The drawable to display as a placeholder.
-
fallback
@NonNull()@CheckResult() T fallback(@DrawableRes() int resourceId)
Sets a resource to display if the model provided to is
{@code null}.If a fallback is not set, null models will cause the error drawable to be displayed. If theerror drawable is not set, the placeholder will be displayed.
Replaces any previous calls to this method or fallback.
- Parameters:
resourceId- The id of the resource to use as a fallback.
-
error
@NonNull()@CheckResult() T error(@Nullable() Drawable drawable)
- Parameters:
drawable- The drawable to display.
-
error
@NonNull()@CheckResult() T error(@DrawableRes() int resourceId)
Sets a resource to display if a load fails.
Replaces any previous calls to this method or error
- Parameters:
resourceId- The id of the resource to use as a placeholder.
-
theme
@NonNull()@CheckResult() T theme(@Nullable() Resources.Theme theme)
Sets the Resources.Theme to apply when loading Drawablesfor resource ids provided via error, placeholder, and .
The theme is NOT applied in the decoder that will attempt to decode a givenresource id model on ImageModule background threads. The theme is used exclusively on the mainthread to obtain placeholder/error/fallback drawables to avoid leaking Activities.
If the android.content.Context of the android.app.Fragment or used to start this load has a different , the Resources.Theme providedhere will override the Resources.Theme of the .
- Parameters:
theme- The theme to use when loading Drawables.
-
skipMemoryCache
@NonNull()@CheckResult() T skipMemoryCache(boolean skip)
Allows the loaded resource to skip the memory cache.
Note - this is not a guarantee. If a request is already pending for this resource and thatrequest is not also skipping the memory cache, the resource will be cached in memory.
- Parameters:
skip- True to allow the resource to skip the memory cache.
-
override
@NonNull()@CheckResult() T override(int width, int height)
Overrides the com.mobwith.imgmodule.request.target.Target's width and height with thegiven values. This is useful for thumbnails, and should only be used for other cases when youneed a very specific image size.
- Parameters:
width- The width in pixels to use to load the resource.height- The height in pixels to use to load the resource.
-
override
@NonNull()@CheckResult() T override(int size)
Overrides the com.mobwith.imgmodule.request.target.Target's width and height with thegiven size.
- Parameters:
size- The width and height to use.
-
signature
@NonNull()@CheckResult() T signature(@NonNull() Key signature)
Sets some additional data to be mixed in to the memory and disk cache keys allowing the callermore control over when cached data is invalidated.
Note - The signature does not replace the cache key, it is purely additive.
- Parameters:
signature- A unique non-null Key representing the current state of the model thatwill be mixed in to the cache key.
-
clone
@CheckResult() T clone()
Returns a copy of this request builder with all of the options put so far on this builder.
This method returns a "deep" copy in that all non-immutable arguments are copied such thatchanges to one builder will not affect the other builder. However, in addition to immutablearguments, the current model is not copied copied so changes to the model will affect bothbuilders.
Even if this object was locked, the cloned object returned from this method will not belocked.
-
isTransformationSet
final boolean isTransformationSet()
-
encodeFormat
@NonNull()@CheckResult() T encodeFormat(@NonNull() Bitmap.CompressFormat format)
-
encodeQuality
@NonNull()@CheckResult() T encodeQuality(@IntRange(from = 0, to = 100) int quality)
Sets the value for key COMPRESSION_QUALITY.
-
frame
@NonNull()@CheckResult() T frame(@IntRange(from = 0) long frameTimeMicros)
Sets the time position of the frame to extract from a video.
This is a component option specific to VideoDecoder. If the default video decoder isreplaced or skipped because of your configuration, this option may be ignored.
- Parameters:
frameTimeMicros- The time position in microseconds of the desired frame.
-
format
@NonNull()@CheckResult() T format(@NonNull() DecodeFormat format)
Sets the DecodeFormat to use when decoding Bitmap objects using and ImageModule default GIF decoders.
DecodeFormat is a request, not a requirement. It's possible the resource will bedecoded using a decoder that cannot control the format ( for example), or that the decoder may choose to ignorethe requested format if it can't display the image (i.e. RGB_565 is requested, but the imagehas alpha).
This is a component option specific to Downsampler and ImageModule GIF decoders. If thedefault Bitmap decoders are replaced or skipped because of your configuration, this option maybe ignored.
To set only the format used when decoding Bitmaps, use set}and DECODE_FORMAT. To set only the format used when decoding GIF frames,use set and DECODE_FORMAT.
-
disallowHardwareConfig
@NonNull()@CheckResult() T disallowHardwareConfig()
Disables the use of HARDWARE in Downsampler toavoid errors caused by inspecting Bitmap pixels, drawing with hardware support disabled,drawing to android.graphics.Canvass backed by Bitmaps etc.
It's almost never safe to set ALLOW_HARDWARE_CONFIG to
{@code true}sowe only provide a way to disable hardware configs entirely. If no option is set for , ImageModule will set the value per request based on whether ornot a Transformation is applied and if one is, the type of Transformation applied. Built in transformations like FitCenter and can safely use because they can be entirely replaced by scalingwithin Downsampler. Transformations like circleCrop that can't bereplicated by Downsampler cannot use HARDWARE because cannot be drawn to android.graphics.Canvass,which is required by most Transformations.
-
downsample
@NonNull()@CheckResult() T downsample(@NonNull() DownsampleStrategy strategy)
Sets the DownsampleStrategy to use when decoding Bitmaps using .
This is a component option specific to Downsampler. If the defautlt Bitmap decoderis replaced or skipped because of your configuration, this option may be ignored.
-
timeout
@NonNull()@CheckResult() T timeout(@IntRange(from = 0) int timeoutMs)
Sets the read and write timeout for the http requests used to load the image.
This is a component option specific to ImageModule default networking library and . If you use any other networkinglibrary including ImageModule Volley or OkHttp integration libraries, this option will be ignored.
- Parameters:
timeoutMs- The read and write timeout in milliseconds.
-
optionalCenterCrop
@NonNull()@CheckResult() T optionalCenterCrop()
Applies com.mobwith.imgmodule.load.resource.bitmap.CenterCrop to all default types, andignores unknown types.
This will override previous calls to dontTransform.
-
centerCrop
@NonNull()@CheckResult() T centerCrop()
Applies CenterCrop to all default types and throws an exception if asked to transforman unknown type.
this will override previous calls to dontTransform ()}.
-
optionalFitCenter
@NonNull()@CheckResult() T optionalFitCenter()
Applies FitCenter and to all default types, FIT_CENTER toimage types, and ignores unknown types.
This will override previous calls to dontTransform and previous calls to .
-
fitCenter
@NonNull()@CheckResult() T fitCenter()
Applies FitCenter and to all default types, FIT_CENTER toimage types, and throws an exception if asked to transform an unknown type.
This will override previous calls to dontTransform and previous calls to .
-
optionalCenterInside
@NonNull()@CheckResult() T optionalCenterInside()
Applies com.mobwith.imgmodule.load.resource.bitmap.CenterInside to all default types, CENTER_INSIDE to image types, and ignores unknown types.
This will override previous calls to dontTransform and previous calls to .
-
centerInside
@NonNull()@CheckResult() T centerInside()
Applies CenterInside to all default types, CENTER_INSIDE toimage types and throws an exception if asked to transform an unknown type.
This will override previous calls to dontTransform and previous calls to .
-
optionalCircleCrop
@NonNull()@CheckResult() T optionalCircleCrop()
Applies CircleCrop to all default types, and ignores unknown types.
This will override previous calls to dontTransform.
-
circleCrop
@NonNull()@CheckResult() T circleCrop()
Applies CircleCrop to all default types and throws an exception if asked to transforman unknown type.
This will override previous calls to dontTransform.
-
transform
@NonNull()@CheckResult() T transform(@NonNull() Transformation<Bitmap> transformation)
Applies the given Transformation for Bitmaps to the default types(Bitmap, BitmapDrawable, and ) and throws an exception if asked totransform an unknown type.
This will override previous calls to dontTransform.
- Parameters:
transformation- Any Transformation for Bitmaps.
-
transform
@NonNull()@CheckResult() T transform(@NonNull() Array<Transformation<Bitmap>> transformations)
Applies the given Transformations in the given order for Bitmaps to thedefault types (Bitmap, BitmapDrawable, and ) and throws an exception if asked totransform an unknown type.
This will override previous calls to dontTransform.
- Parameters:
transformations- One or more Transformations for Bitmaps.
-
transforms
@NonNull()@CheckResult()@Deprecated() T transforms(@NonNull() Array<Transformation<Bitmap>> transformations)
Applies the given Transformations in the given order for Bitmaps to thedefault types (Bitmap, BitmapDrawable, and ) and throws an exception if asked totransform an unknown type.
This will override previous calls to dontTransform.
- Parameters:
transformations- One or more Transformations for Bitmaps.
-
optionalTransform
@NonNull()@CheckResult() T optionalTransform(@NonNull() Transformation<Bitmap> transformation)
Applies the given Transformation for Bitmaps to the default types(Bitmap, BitmapDrawable, and ) and ignores unknown types.
This will override previous calls to dontTransform.
- Parameters:
transformation- Any Transformation for Bitmaps.
-
optionalTransform
@NonNull()@CheckResult() <Y> T optionalTransform(@NonNull() Class<Y> resourceClass, @NonNull() Transformation<Y> transformation)
Applies the given Transformation for any decoded resource of the given type and allowsunknown resource types to be ignored.
Users can apply different transformations for each resource class. Applying a for a resource type that already has a Transformation will override theprevious call.
If any calls are made to the non-optional transform methods, then attempting to transform anunknown resource class will throw an exception. To allow unknown types, users must always callthe optional version of each method.
This will override previous calls to dontTransform.
- Parameters:
resourceClass- The type of resource to transform.transformation- The Transformation to apply.
-
transform
@NonNull()@CheckResult() <Y> T transform(@NonNull() Class<Y> resourceClass, @NonNull() Transformation<Y> transformation)
Applies the given Transformation for any decoded resource of the given type and throwsif asked to transform an unknown resource type.
This will override previous calls to dontTransform.
- Parameters:
resourceClass- The type of resource to transform.transformation- The Transformation to apply.
-
dontTransform
@NonNull()@CheckResult() T dontTransform()
Removes all applied Transformations for all resource classes and allowsunknown resource types to be transformed without throwing an exception.
-
dontAnimate
@NonNull()@CheckResult() T dontAnimate()
-
apply
@NonNull()@CheckResult() T apply(@NonNull() BaseRequestOptions<out Object> o)
Updates this options set with any options that are explicitly set in the given
{@code T}objectand returns this object if autoClone is disabled or a new{@code T}object if is enabled.{@code #apply}only replaces those values that are explicitly set in the given{@code T}. Ifyou need to completely reset all previously set options, create a new{@code T}object insteadof using this method.The options that will be set to values in the returned
{@code T}object is the intersectionof the set of options in this{@code T}object and the given{@code T}object that wereexplicitly set. If the values of any of the options conflict, the values in the returned{@code * T}object will be set to those in the given{@code T}object.
-
hashCode
int hashCode()
-
lock
@NonNull() T lock()
Throws if any further mutations are attempted.
Once locked, the only way to unlock is to use clone
-
autoClone
@NonNull() T autoClone()
Similar to lock except that mutations cause a clone operation to happenbefore the mutation resulting in all methods returning a new Object and leaving the originallocked object unmodified.
Auto clone is not retained by cloned objects returned from mutations. The cloned objects aremutable and are not locked.
-
isDiskCacheStrategySet
final boolean isDiskCacheStrategySet()
-
isSkipMemoryCacheSet
final boolean isSkipMemoryCacheSet()
-
isMemoryCacheable
final boolean isMemoryCacheable()
-
isPrioritySet
final boolean isPrioritySet()
-
isValidOverride
final boolean isValidOverride()
-
-
-
-