TtImageLoaderInterceptor

Simplifies testing of remotely downloaded images.

When using either RemoteDrawable or TtImageLoader directly, this class by default will immediately and synchronously complete the retrieval of Uris referring to locally resolvable Drawables. When a placeholder is set and the Uri cannot be instantly resolved, it is loaded directly as if it is a locally resolvable Drawable.

Any other types of requests that cannot be resolve synchronously, such as content provider URIs or internet URIs, will by default complete successfully and return R.drawable.tt_test_default_remote_drawable.

Use resolveUri and failUri to override this behavior and respectively choose a custom drawable to load, or make the request fail.

Constructors

Link copied to clipboard
constructor(context: Context)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun failUri(uri: Uri)

Intercept any requests to load uri, failing their resolution and causing TtImageLoader to either display the placeholder if set, or the error image if set, or nothing.

Link copied to clipboard
fun reset()

Remove all interception rules previously defined with resolveUri and failUri.

Link copied to clipboard
fun resolveUri(uri: Uri, result: Drawable)

Intercept any requests to load uri and respond those immediately with the given Drawable.

Link copied to clipboard
fun start()

Start intercepting requests for TtImageLoader.

Link copied to clipboard
fun stop()

Restore the normal TtImageLoader behavior.