-
public final class ImageRequest.Builder
-
-
Constructor Summary
Constructors Constructor Description ImageRequest.Builder(Context context)ImageRequest.Builder(ImageRequest request, Context context)ImageRequest.Builder(ImageRequest request)
-
Method Summary
Modifier and Type Method Description final <ERROR CLASS>data(Object data)Set the data to load. final <ERROR CLASS>memoryCacheKey(String key)Set the memory cache key for this request. final <ERROR CLASS>memoryCacheKey(MemoryCache.Key key)Set the memory cache key for this request. final <ERROR CLASS>diskCacheKey(String key)Set the disk cache key for this request. final <ERROR CLASS>listener(Function1<ImageRequest, Unit> onStart, Function1<ImageRequest, Unit> onCancel, Function2<ImageRequest, ErrorResult, Unit> onError, Function2<ImageRequest, SuccessResult, Unit> onSuccess)Convenience function to create and set the Listener. final <ERROR CLASS>listener(ImageRequest.Listener listener)Set the Listener. final <ERROR CLASS>dispatcher(CoroutineDispatcher dispatcher)final <ERROR CLASS>interceptorDispatcher(CoroutineDispatcher dispatcher)final <ERROR CLASS>fetcherDispatcher(CoroutineDispatcher dispatcher)final <ERROR CLASS>decoderDispatcher(CoroutineDispatcher dispatcher)final <ERROR CLASS>transformationDispatcher(CoroutineDispatcher dispatcher)final <ERROR CLASS>transformations(Transformation transformations)Set the list of Transformations to be applied to this request. final <ERROR CLASS>transformations(List<Transformation> transformations)Set the list of Transformations to be applied to this request. final <ERROR CLASS>bitmapConfig(Bitmap.Config config)final <ERROR CLASS>colorSpace(ColorSpace colorSpace)Set the preferred ColorSpace. final <ERROR CLASS>size(@Px() Integer size)Set the requested width/height. final <ERROR CLASS>size(@Px() Integer width, @Px() Integer height)Set the requested width/height. final <ERROR CLASS>size(Dimension width, Dimension height)Set the requested width/height. final <ERROR CLASS>size(Size size)Set the requested width/height. final <ERROR CLASS>size(SizeResolver resolver)Set the SizeResolver to resolve the requested width/height. final <ERROR CLASS>scale(Scale scale)Set the scaling algorithm that will be used to fit/fill the image into the size provided by sizeResolver. final <ERROR CLASS>precision(Precision precision)Set the precision for the size of the loaded image. final <T extends Any> <ERROR CLASS>fetcherFactory(Fetcher.Factory<T> factory)Use factory to handle fetching any image data. final <T extends Any> <ERROR CLASS>fetcherFactory(Fetcher.Factory<T> factory, Class<T> type)Use factory to handle fetching any image data. final <ERROR CLASS>decoderFactory(Decoder.Factory factory)Use factory to handle decoding any image data. final <ERROR CLASS>allowConversionToBitmap(Boolean enable)Allow converting the result drawable to a bitmap to apply any transformations. final <ERROR CLASS>allowHardware(Boolean enable)final <ERROR CLASS>allowRgb565(Boolean enable)final <ERROR CLASS>premultipliedAlpha(Boolean enable)Enable/disable pre-multiplication of the color (RGB) channels of the decoded image by the alpha channel. final <ERROR CLASS>memoryCachePolicy(CachePolicy policy)Enable/disable reading/writing from/to the memory cache. final <ERROR CLASS>diskCachePolicy(CachePolicy policy)Enable/disable reading/writing from/to the disk cache. final <ERROR CLASS>networkCachePolicy(CachePolicy policy)Enable/disable reading from the network. final <ERROR CLASS>headers(Headers headers)Set the Headers for any network operations performed by this request. final <ERROR CLASS>addHeader(String name, String value)Add a header for any network operations performed by this request. final <ERROR CLASS>setHeader(String name, String value)Set a header for any network operations performed by this request. final <ERROR CLASS>removeHeader(String name)Remove all network headers with the key name. final <T extends Any> <ERROR CLASS>tag(T tag)Attach tag to this request using T as the key. final <T extends Any> <ERROR CLASS>tag(Class<in T> type, T tag)Attach tag to this request using type as the key. final <ERROR CLASS>tags(Tags tags)Set the tags for this request. final <ERROR CLASS>placeholderMemoryCacheKey(String key)Set the memory cache key whose value will be used as the placeholder drawable. final <ERROR CLASS>placeholderMemoryCacheKey(MemoryCache.Key key)Set the memory cache key whose value will be used as the placeholder drawable. final <ERROR CLASS>placeholder(@DrawableRes() Integer drawableResId)Set the placeholder drawable to use when the request starts. final <ERROR CLASS>placeholder(Drawable drawable)Set the placeholder drawable to use when the request starts. final <ERROR CLASS>error(@DrawableRes() Integer drawableResId)Set the error drawable to use if the request fails. final <ERROR CLASS>error(Drawable drawable)Set the error drawable to use if the request fails. final <ERROR CLASS>fallback(@DrawableRes() Integer drawableResId)Set the fallback drawable to use if data is null. final <ERROR CLASS>fallback(Drawable drawable)Set the fallback drawable to use if data is null. final <ERROR CLASS>target(ImageView imageView)Convenience function to set imageView as the Target. final <ERROR CLASS>target(Function1<Drawable, Unit> onStart, Function1<Drawable, Unit> onError, Function1<Drawable, Unit> onSuccess)Convenience function to create and set the Target. final <ERROR CLASS>target(Target target)Set the Target. final <ERROR CLASS>crossfade(Boolean enable)final <ERROR CLASS>crossfade(Integer durationMillis)final <ERROR CLASS>transitionFactory(Transition.Factory transition)final <ERROR CLASS>lifecycle(LifecycleOwner owner)Set the Lifecycle for this request. final <ERROR CLASS>lifecycle(Lifecycle lifecycle)Set the Lifecycle for this request. final <ERROR CLASS>setParameter(String key, Object value, String memoryCacheKey)Set a parameter for this request. final <ERROR CLASS>setParameter(String key, Object value)Set a parameter for this request. final <ERROR CLASS>removeParameter(String key)Remove a parameter from this request. final <ERROR CLASS>parameters(Parameters parameters)Set the parameters for this request. final <ERROR CLASS>defaults(DefaultRequestOptions defaults)Set the defaults for any unset request values. final ImageRequestbuild()Create a new ImageRequest. final ImageRequest.Builderfetcher(Fetcher fetcher)final ImageRequest.Builderdecoder(Decoder decoder)final ImageRequest.Buildertransition(Transition transition)-
-
Constructor Detail
-
ImageRequest.Builder
ImageRequest.Builder(Context context)
-
ImageRequest.Builder
ImageRequest.Builder(ImageRequest request, Context context)
-
ImageRequest.Builder
ImageRequest.Builder(ImageRequest request)
-
-
Method Detail
-
data
final <ERROR CLASS> data(Object data)
Set the data to load.
The default supported data types are:
Uri ("android.resource", "content", "file", "http", and "https" schemes only)
HttpUrl
-
memoryCacheKey
final <ERROR CLASS> memoryCacheKey(String key)
Set the memory cache key for this request.
If this is null or is not set, the ImageLoader will compute a memory cache key.
-
memoryCacheKey
final <ERROR CLASS> memoryCacheKey(MemoryCache.Key key)
Set the memory cache key for this request.
If this is null or is not set, the ImageLoader will compute a memory cache key.
-
diskCacheKey
final <ERROR CLASS> diskCacheKey(String key)
Set the disk cache key for this request.
If this is null or is not set, the ImageLoader will compute a disk cache key.
-
listener
final <ERROR CLASS> listener(Function1<ImageRequest, Unit> onStart, Function1<ImageRequest, Unit> onCancel, Function2<ImageRequest, ErrorResult, Unit> onError, Function2<ImageRequest, SuccessResult, Unit> onSuccess)
Convenience function to create and set the Listener.
-
listener
final <ERROR CLASS> listener(ImageRequest.Listener listener)
Set the Listener.
-
dispatcher
final <ERROR CLASS> dispatcher(CoroutineDispatcher dispatcher)
-
interceptorDispatcher
final <ERROR CLASS> interceptorDispatcher(CoroutineDispatcher dispatcher)
-
fetcherDispatcher
final <ERROR CLASS> fetcherDispatcher(CoroutineDispatcher dispatcher)
-
decoderDispatcher
final <ERROR CLASS> decoderDispatcher(CoroutineDispatcher dispatcher)
-
transformationDispatcher
final <ERROR CLASS> transformationDispatcher(CoroutineDispatcher dispatcher)
-
transformations
final <ERROR CLASS> transformations(Transformation transformations)
Set the list of Transformations to be applied to this request.
-
transformations
final <ERROR CLASS> transformations(List<Transformation> transformations)
Set the list of Transformations to be applied to this request.
-
bitmapConfig
final <ERROR CLASS> bitmapConfig(Bitmap.Config config)
-
colorSpace
final <ERROR CLASS> colorSpace(ColorSpace colorSpace)
Set the preferred ColorSpace.
This is not guaranteed and a different color space may be used in some situations.
-
size
final <ERROR CLASS> size(@Px() Integer width, @Px() Integer height)
Set the requested width/height.
-
size
final <ERROR CLASS> size(SizeResolver resolver)
Set the SizeResolver to resolve the requested width/height.
-
precision
final <ERROR CLASS> precision(Precision precision)
Set the precision for the size of the loaded image.
The default value is Precision.AUTOMATIC, which uses the logic in allowInexactSize to determine if output image's dimensions must match the input size and scale exactly.
NOTE: If size is Size.ORIGINAL, the returned image's size will always be equal to or greater than the image's original size.
-
fetcherFactory
final <T extends Any> <ERROR CLASS> fetcherFactory(Fetcher.Factory<T> factory)
Use factory to handle fetching any image data.
If this is null or is not set the ImageLoader will find an applicable fetcher in its ComponentRegistry.
-
fetcherFactory
final <T extends Any> <ERROR CLASS> fetcherFactory(Fetcher.Factory<T> factory, Class<T> type)
Use factory to handle fetching any image data.
If this is null or is not set the ImageLoader will find an applicable fetcher in its ComponentRegistry.
-
decoderFactory
final <ERROR CLASS> decoderFactory(Decoder.Factory factory)
Use factory to handle decoding any image data.
If this is null or is not set the ImageLoader will find an applicable decoder in its ComponentRegistry.
-
allowConversionToBitmap
final <ERROR CLASS> allowConversionToBitmap(Boolean enable)
Allow converting the result drawable to a bitmap to apply any transformations.
If false and the result drawable is not a BitmapDrawable any transformations will be ignored.
-
allowHardware
final <ERROR CLASS> allowHardware(Boolean enable)
-
allowRgb565
final <ERROR CLASS> allowRgb565(Boolean enable)
-
premultipliedAlpha
final <ERROR CLASS> premultipliedAlpha(Boolean enable)
Enable/disable pre-multiplication of the color (RGB) channels of the decoded image by the alpha channel.
The default behavior is to enable pre-multiplication but in some environments it can be necessary to disable this feature to leave the source pixels unmodified.
-
memoryCachePolicy
final <ERROR CLASS> memoryCachePolicy(CachePolicy policy)
Enable/disable reading/writing from/to the memory cache.
-
diskCachePolicy
final <ERROR CLASS> diskCachePolicy(CachePolicy policy)
Enable/disable reading/writing from/to the disk cache.
-
networkCachePolicy
final <ERROR CLASS> networkCachePolicy(CachePolicy policy)
Enable/disable reading from the network.
NOTE: Disabling writes has no effect.
-
headers
final <ERROR CLASS> headers(Headers headers)
Set the Headers for any network operations performed by this request.
-
addHeader
final <ERROR CLASS> addHeader(String name, String value)
Add a header for any network operations performed by this request.
-
setHeader
final <ERROR CLASS> setHeader(String name, String value)
Set a header for any network operations performed by this request.
-
removeHeader
final <ERROR CLASS> removeHeader(String name)
Remove all network headers with the key name.
-
placeholderMemoryCacheKey
final <ERROR CLASS> placeholderMemoryCacheKey(String key)
Set the memory cache key whose value will be used as the placeholder drawable.
If there is no value in the memory cache for key, fall back to placeholder.
-
placeholderMemoryCacheKey
final <ERROR CLASS> placeholderMemoryCacheKey(MemoryCache.Key key)
Set the memory cache key whose value will be used as the placeholder drawable.
If there is no value in the memory cache for key, fall back to placeholder.
-
placeholder
final <ERROR CLASS> placeholder(@DrawableRes() Integer drawableResId)
Set the placeholder drawable to use when the request starts.
-
placeholder
final <ERROR CLASS> placeholder(Drawable drawable)
Set the placeholder drawable to use when the request starts.
-
error
final <ERROR CLASS> error(@DrawableRes() Integer drawableResId)
Set the error drawable to use if the request fails.
-
error
final <ERROR CLASS> error(Drawable drawable)
Set the error drawable to use if the request fails.
-
fallback
final <ERROR CLASS> fallback(@DrawableRes() Integer drawableResId)
Set the fallback drawable to use if data is null.
-
fallback
final <ERROR CLASS> fallback(Drawable drawable)
Set the fallback drawable to use if data is null.
-
target
final <ERROR CLASS> target(Function1<Drawable, Unit> onStart, Function1<Drawable, Unit> onError, Function1<Drawable, Unit> onSuccess)
Convenience function to create and set the Target.
-
transitionFactory
final <ERROR CLASS> transitionFactory(Transition.Factory transition)
-
lifecycle
final <ERROR CLASS> lifecycle(LifecycleOwner owner)
Set the Lifecycle for this request.
-
lifecycle
final <ERROR CLASS> lifecycle(Lifecycle lifecycle)
Set the Lifecycle for this request.
Requests are queued while the lifecycle is not at least Lifecycle.State.STARTED. Requests are cancelled when the lifecycle reaches Lifecycle.State.DESTROYED.
If this is null or is not set the ImageLoader will attempt to find the lifecycle for this request through its context.
-
setParameter
final <ERROR CLASS> setParameter(String key, Object value, String memoryCacheKey)
Set a parameter for this request.
-
setParameter
final <ERROR CLASS> setParameter(String key, Object value)
Set a parameter for this request.
-
removeParameter
final <ERROR CLASS> removeParameter(String key)
Remove a parameter from this request.
-
parameters
final <ERROR CLASS> parameters(Parameters parameters)
Set the parameters for this request.
-
defaults
final <ERROR CLASS> defaults(DefaultRequestOptions defaults)
Set the defaults for any unset request values.
-
build
final ImageRequest build()
Create a new ImageRequest.
-
fetcher
final ImageRequest.Builder fetcher(Fetcher fetcher)
-
decoder
final ImageRequest.Builder decoder(Decoder decoder)
-
transition
final ImageRequest.Builder transition(Transition transition)
-
-
-
-