Builder

class Builder

Constructors

Builder
Link copied to clipboard
fun Builder(context: Context)
Builder
Link copied to clipboard
fun Builder(request: ImageRequest, context: Context = request.context)

Functions

addHeader
Link copied to clipboard
fun addHeader(name: String, value: String): ImageRequest.Builder

Add a header for any network operations performed by this request.

allowConversionToBitmap
Link copied to clipboard
fun allowConversionToBitmap(enable: Boolean): ImageRequest.Builder

Allow converting the result drawable to a bitmap to apply any transformations.

allowHardware
Link copied to clipboard
fun allowHardware(enable: Boolean): ImageRequest.Builder
allowRgb565
Link copied to clipboard
fun allowRgb565(enable: Boolean): ImageRequest.Builder
bitmapConfig
Link copied to clipboard
fun bitmapConfig(config: Bitmap.Config): ImageRequest.Builder
build
Link copied to clipboard
fun build(): ImageRequest

Create a new ImageRequest.

colorSpace
Link copied to clipboard
@RequiresApi(value = 26)
fun colorSpace(colorSpace: ColorSpace): ImageRequest.Builder

Set the preferred ColorSpace.

crossfade
Link copied to clipboard
fun crossfade(enable: Boolean): ImageRequest.Builder
fun crossfade(durationMillis: Int): ImageRequest.Builder
data
Link copied to clipboard
fun data(data: Any?): ImageRequest.Builder

Set the data to load.

decoder
Link copied to clipboard
fun decoder(decoder: Decoder): ImageRequest.Builder

Use decoder to handle decoding any image data.

defaults
Link copied to clipboard
fun defaults(defaults: DefaultRequestOptions): ImageRequest.Builder

Set the defaults for any unset request values.

diskCachePolicy
Link copied to clipboard
fun diskCachePolicy(policy: CachePolicy): ImageRequest.Builder

Enable/disable reading/writing from/to the disk cache.

dispatcher
Link copied to clipboard
fun dispatcher(dispatcher: CoroutineDispatcher): ImageRequest.Builder

Set the CoroutineDispatcher to launch the request.

error
Link copied to clipboard
fun error(drawable: Drawable?): ImageRequest.Builder
fun error(@DrawableRes drawableResId: Int): ImageRequest.Builder

Set the error drawable to use if the request fails.

fallback
Link copied to clipboard
fun fallback(drawable: Drawable?): ImageRequest.Builder
fun fallback(@DrawableRes drawableResId: Int): ImageRequest.Builder

Set the fallback drawable to use if data is null.

fetcher
Link copied to clipboard
inline fun <T : Any> fetcher(fetcher: Fetcher<T>): ImageRequest.Builder

Use fetcher to handle fetching any image data.

headers
Link copied to clipboard
fun headers(headers: Headers): ImageRequest.Builder

Set the Headers for any network operations performed by this request.

lifecycle
Link copied to clipboard
fun lifecycle(lifecycle: Lifecycle?): ImageRequest.Builder
fun lifecycle(owner: LifecycleOwner?): ImageRequest.Builder

Set the Lifecycle for this request.

listener
Link copied to clipboard
fun listener(listener: ImageRequest.Listener?): ImageRequest.Builder

Set the Listener.

inline fun listener(crossinline onStart: (request: ImageRequest) -> Unit = {}, crossinline onCancel: (request: ImageRequest) -> Unit = {}, crossinline onError: (request: ImageRequest, throwable: Throwable) -> Unit = { _, _ -> }, crossinline onSuccess: (request: ImageRequest, metadata: ImageResult.Metadata) -> Unit = { _, _ -> }): ImageRequest.Builder

Convenience function to create and set the Listener.

memoryCacheKey
Link copied to clipboard
fun memoryCacheKey(key: MemoryCache.Key?): ImageRequest.Builder
fun memoryCacheKey(key: String?): ImageRequest.Builder

Set the memory cache key for this request.

memoryCachePolicy
Link copied to clipboard
fun memoryCachePolicy(policy: CachePolicy): ImageRequest.Builder

Enable/disable reading/writing from/to the memory cache.

networkCachePolicy
Link copied to clipboard
fun networkCachePolicy(policy: CachePolicy): ImageRequest.Builder

Enable/disable reading from the network.

parameters
Link copied to clipboard
fun parameters(parameters: Parameters): ImageRequest.Builder

Set the parameters for this request.

placeholder
Link copied to clipboard
fun placeholder(drawable: Drawable?): ImageRequest.Builder
fun placeholder(@DrawableRes drawableResId: Int): ImageRequest.Builder

Set the placeholder drawable to use when the request starts.

placeholderMemoryCacheKey
Link copied to clipboard
fun placeholderMemoryCacheKey(key: MemoryCache.Key?): ImageRequest.Builder
fun placeholderMemoryCacheKey(key: String?): ImageRequest.Builder

Set the memory cache key whose value will be used as the placeholder drawable.

precision
Link copied to clipboard
fun precision(precision: Precision): ImageRequest.Builder

Set the precision for the size of the loaded image.

premultipliedAlpha
Link copied to clipboard
fun premultipliedAlpha(enable: Boolean): ImageRequest.Builder

Enable/disable pre-multiplication of the color (RGB) channels of the decoded image by the alpha channel.

removeHeader
Link copied to clipboard
fun removeHeader(name: String): ImageRequest.Builder

Remove all network headers with the key name.

removeParameter
Link copied to clipboard
fun removeParameter(key: String): ImageRequest.Builder

Remove a parameter from this request.

scale
Link copied to clipboard
fun scale(scale: Scale): ImageRequest.Builder

Set the scaling algorithm that will be used to fit/fill the image into the size provided by sizeResolver.

setHeader
Link copied to clipboard
fun setHeader(name: String, value: String): ImageRequest.Builder

Set a header for any network operations performed by this request.

setParameter
Link copied to clipboard
fun setParameter(key: String, value: Any?, cacheKey: String? = value?.toString()): ImageRequest.Builder

Set a parameter for this request.

size
Link copied to clipboard
fun size(size: Size): ImageRequest.Builder
fun size(@Px size: Int): ImageRequest.Builder
fun size(@Px width: Int, @Px height: Int): ImageRequest.Builder

Set the requested width/height.

fun size(resolver: SizeResolver): ImageRequest.Builder

Set the SizeResolver to resolve the requested width/height.

target
Link copied to clipboard
fun target(imageView: ImageView): ImageRequest.Builder

Convenience function to set imageView as the Target.

fun target(target: Target?): ImageRequest.Builder

Set the Target.

inline fun target(crossinline onStart: (placeholder: Drawable?) -> Unit = {}, crossinline onError: (error: Drawable?) -> Unit = {}, crossinline onSuccess: (result: Drawable) -> Unit = {}): ImageRequest.Builder

Convenience function to create and set the Target.

transformations
Link copied to clipboard
fun transformations(vararg transformations: Transformation): ImageRequest.Builder
fun transformations(transformations: List<Transformation>): ImageRequest.Builder

Set the list of Transformations to be applied to this request.

transition
Link copied to clipboard
fun transition(transition: Transition): ImageRequest.Builder