Builder

class Builder

Constructors

Builder
Link copied to clipboard
fun Builder(context: Context)

Functions

addLastModifiedToFileCacheKey
Link copied to clipboard
fun addLastModifiedToFileCacheKey(enable: Boolean): ImageLoader.Builder

Enables adding File.lastModified to the memory cache key when loading an image from a File.

allowHardware
Link copied to clipboard
fun allowHardware(enable: Boolean): ImageLoader.Builder

Allow the use of Bitmap.Config.HARDWARE.

allowRgb565
Link copied to clipboard
fun allowRgb565(enable: Boolean): ImageLoader.Builder

Allow automatically using Bitmap.Config.RGB_565 when an image is guaranteed to not have alpha.

availableMemoryPercentage
Link copied to clipboard
fun availableMemoryPercentage(@FloatRange(from = 0.0, to = 1.0percent: Double): ImageLoader.Builder

Set the percentage of available memory to devote to this ImageLoader's memory cache and bitmap pool.

bitmapConfig
Link copied to clipboard
fun bitmapConfig(bitmapConfig: Bitmap.Config): ImageLoader.Builder

Set the preferred Bitmap.Config.

bitmapPoolingEnabled
Link copied to clipboard
fun bitmapPoolingEnabled(enable: Boolean): ImageLoader.Builder

Enables counting references to bitmaps so they can be automatically reused by a BitmapPool when their reference count reaches zero.

bitmapPoolPercentage
Link copied to clipboard
fun bitmapPoolPercentage(@FloatRange(from = 0.0, to = 1.0percent: Double): ImageLoader.Builder

Set the percentage of memory allocated to this ImageLoader to allocate to bitmap pooling.

build
Link copied to clipboard
fun build(): ImageLoader

Create a new ImageLoader instance.

callFactory
Link copied to clipboard
fun callFactory(initializer: () -> Call.Factory): ImageLoader.Builder

Set a lazy callback to create the Call.Factory used for network requests.

fun callFactory(callFactory: Call.Factory): ImageLoader.Builder

Set the Call.Factory used for network requests.

componentRegistry
Link copied to clipboard
fun componentRegistry(registry: ComponentRegistry): ImageLoader.Builder
inline fun componentRegistry(builder: ComponentRegistry.Builder.() -> Unit): ImageLoader.Builder

Build and set the ComponentRegistry.

crossfade
Link copied to clipboard
fun crossfade(enable: Boolean): ImageLoader.Builder

Enable a crossfade animation with duration CrossfadeDrawable.DEFAULT_DURATION milliseconds when a request completes successfully.

fun crossfade(durationMillis: Int): ImageLoader.Builder

Enable a crossfade animation with durationMillis milliseconds when a request completes successfully.

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

Set the default disk cache policy.

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

The default CoroutineDispatcher to run image requests on.

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

Set the default error drawable to use when a request fails.

eventListener
Link copied to clipboard
fun eventListener(factory: EventListener.Factory): ImageLoader.Builder

Set the EventListener.Factory to create per-request EventListeners.

fun eventListener(listener: EventListener): ImageLoader.Builder

Set a single EventListener that will receive all callbacks for requests launched by this image loader.

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

Set the default fallback drawable to use if ImageRequest.data is null.

launchInterceptorChainOnMainThread
Link copied to clipboard
fun launchInterceptorChainOnMainThread(enable: Boolean): ImageLoader.Builder

Enables launching the Interceptor chain on the main thread.

logger
Link copied to clipboard
fun logger(logger: Logger?): ImageLoader.Builder

Set the Logger to write logs to.

memoryCache
Link copied to clipboard
fun memoryCache(memoryCache: MemoryCache): ImageLoader.Builder

Set the MemoryCache. This also sets the BitmapPool to the instance used by this MemoryCache.

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

Set the default memory cache policy.

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

Set the default network cache policy.

networkObserverEnabled
Link copied to clipboard
fun networkObserverEnabled(enable: Boolean): ImageLoader.Builder

Enables short circuiting network requests if the device is offline.

okHttpClient
Link copied to clipboard
fun okHttpClient(initializer: () -> OkHttpClient): ImageLoader.Builder

Set a lazy callback to create the OkHttpClient used for network requests.

fun okHttpClient(okHttpClient: OkHttpClient): ImageLoader.Builder

Set the OkHttpClient used for network requests.

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

Set the default placeholder drawable to use when a request starts.

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

Set the default precision for a request. Precision controls whether the size of the loaded image must match the request's size exactly or not.

trackWeakReferences
Link copied to clipboard
fun trackWeakReferences(enable: Boolean): ImageLoader.Builder

Enables weak reference tracking of loaded images.

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

Set the default Transition for each request.