SizeLimitedBitmapLoader


@UnstableApi
public final class SizeLimitedBitmapLoader implements BitmapLoader


A BitmapLoader that limits the size of bitmaps loaded by decodeBitmap or loadBitmap request. Bitmaps with width or height larger than maxBitmapSize will be scaled down so that the larger dimension will be equal or less than maxBitmapSize.

Summary

Public constructors

SizeLimitedBitmapLoader(
    BitmapLoader bitmapLoader,
    int maxBitmapSize,
    boolean makeShared
)

Creates an instance that size limits the bitmap loaded by the BitmapLoader.

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

SizeLimitedBitmapLoader

public SizeLimitedBitmapLoader(
    BitmapLoader bitmapLoader,
    int maxBitmapSize,
    boolean makeShared
)

Creates an instance that size limits the bitmap loaded by the BitmapLoader.

Parameters
BitmapLoader bitmapLoader

The BitmapLoader.

int maxBitmapSize

The maximum size to limit the loaded Bitmap instances to.

boolean makeShared

Whether the Bitmap should be converted to an immutable, sharable instance that is most efficient for repeated transfer over binder interfaces.

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.