CacheBitmapLoader


@UnstableApi
public final class CacheBitmapLoader implements BitmapLoader


A BitmapLoader that caches the result of the last decodeBitmap, loadBitmap or loadBitmapFromMetadata request.

Requests are fulfilled from the last bitmap load request when the last bitmap is requested from the same data, the same uri, or the same artworkUri or artworkData. If the request doesn't match the previous request, the request is forwarded to the provided BitmapLoader and the result is cached.

Summary

Public constructors

Creates an instance that is able to cache the last bitmap load request to the given bitmap loader.

Public methods

ListenableFuture<Bitmap>
decodeBitmap(byte[] data)

Decodes an image from compressed binary data.

ListenableFuture<Bitmap>

Loads an image from uri.

@Nullable ListenableFuture<Bitmap>

Loads an image from MediaMetadata.

boolean

Returns whether the given mimeType is supported.

Public constructors

CacheBitmapLoader

public CacheBitmapLoader(BitmapLoader bitmapLoader)

Creates an instance that is able to cache the last bitmap load request to the given bitmap loader.

Public methods

decodeBitmap

public ListenableFuture<BitmapdecodeBitmap(byte[] data)

Decodes an image from compressed binary data.

loadBitmap

public ListenableFuture<BitmaploadBitmap(Uri uri)

Loads an image from uri.

loadBitmapFromMetadata

public @Nullable ListenableFuture<BitmaploadBitmapFromMetadata(MediaMetadata metadata)

Loads an image from MediaMetadata. Returns null if metadata doesn't contain bitmap information.

By default, the method will try to decode an image from artworkData if it is present. Otherwise, the method will try to load an image from artworkUri if it is present. The method will return null if neither artworkData nor artworkUri is present.

supportsMimeType

public boolean supportsMimeType(String mimeType)

Returns whether the given mimeType is supported.