PoolableViewTarget

interface PoolableViewTarget<T : View> : ViewTarget<T>

A ViewTarget that supports Bitmap pooling.

Implementing PoolableViewTarget opts this target into bitmap pooling. This allows Coil to re-use Bitmaps given to this target, which can conserve memory by avoiding a new Bitmap allocation.

To opt out of bitmap pooling, implement ViewTarget instead.

Implementing PoolableViewTarget requires that you must stop using the previous Drawable as soon as the next PoolableViewTarget lifecycle method is called; one of:

Target.onStart, Target.onSuccess, Target.onError, PoolableViewTarget.onClear.

For example, a PoolableViewTarget must stop using the placeholder drawable from Target.onStart as soon as Target.onSuccess is called.

Continuing to use the previous Drawable after the next lifecycle method is called can cause rendering issues and/or throw exceptions.

See also

Functions

onClear
Link copied to clipboard
abstract fun onClear()

Called when the current drawable is no longer usable. Targets must stop using the current Drawable.

onError
Link copied to clipboard
open fun onError(error: Drawable?)

Called if an error occurs while executing the request.

onStart
Link copied to clipboard
open fun onStart(placeholder: Drawable?)

Called when the request starts.

onSuccess
Link copied to clipboard
open fun onSuccess(result: Drawable)

Called if the request completes successfully.

Properties

view
Link copied to clipboard
abstract val view: T

The View used by this Target. This field should be immutable.

Inheritors

ImageViewTarget
Link copied to clipboard