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 |
|---|
CacheBitmapLoader(BitmapLoader bitmapLoader)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> |
loadBitmap(Uri uri)Loads an image from |
@Nullable ListenableFuture<Bitmap> |
loadBitmapFromMetadata(MediaMetadata metadata)Loads an image from |
boolean |
supportsMimeType(String mimeType)Returns whether the given |
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<Bitmap> decodeBitmap(byte[] data)
Decodes an image from compressed binary data.
loadBitmapFromMetadata
public @Nullable ListenableFuture<Bitmap> loadBitmapFromMetadata(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.