DataSourceBitmapLoader


@UnstableApi
class DataSourceBitmapLoader : BitmapLoader


A BitmapLoader implementation that uses a DataSource to support fetching images from URIs and BitmapFactory to load them into Bitmap.

Loading tasks are delegated to a ListeningExecutorService defined during construction. If no executor service is passed, all tasks are delegated to a single-thread executor service that is shared between instances of this class.

Summary

Public constructors

Creates an instance that uses a DefaultHttpDataSource for image loading and delegates loading tasks to a newSingleThreadExecutor.

DataSourceBitmapLoader(
    listeningExecutorService: ListeningExecutorService!,
    dataSourceFactory: DataSource.Factory!
)

Creates an instance that delegates loading tasks to the ListeningExecutorService.

DataSourceBitmapLoader(
    listeningExecutorService: ListeningExecutorService!,
    dataSourceFactory: DataSource.Factory!,
    options: BitmapFactory.Options?
)

Creates an instance that delegates loading tasks to the ListeningExecutorService.

Public functions

ListenableFuture<Bitmap!>!

Decodes an image from compressed binary data.

ListenableFuture<Bitmap!>!
loadBitmap(uri: Uri!)

Loads an image from uri.

Boolean

Returns whether the given mimeType is supported.

Constants

DEFAULT_EXECUTOR_SERVICE

const val DEFAULT_EXECUTOR_SERVICESupplier<ListeningExecutorService!>!

Public constructors

DataSourceBitmapLoader

DataSourceBitmapLoader(context: Context!)

Creates an instance that uses a DefaultHttpDataSource for image loading and delegates loading tasks to a newSingleThreadExecutor.

DataSourceBitmapLoader

DataSourceBitmapLoader(
    listeningExecutorService: ListeningExecutorService!,
    dataSourceFactory: DataSource.Factory!
)

Creates an instance that delegates loading tasks to the ListeningExecutorService.

Parameters
listeningExecutorService: ListeningExecutorService!

The ListeningExecutorService.

dataSourceFactory: DataSource.Factory!

The DataSource.Factory that creates the DataSource used to load the image.

DataSourceBitmapLoader

DataSourceBitmapLoader(
    listeningExecutorService: ListeningExecutorService!,
    dataSourceFactory: DataSource.Factory!,
    options: BitmapFactory.Options?
)

Creates an instance that delegates loading tasks to the ListeningExecutorService.

Parameters
listeningExecutorService: ListeningExecutorService!

The ListeningExecutorService.

dataSourceFactory: DataSource.Factory!

The DataSource.Factory that creates the DataSource used to load the image.

options: BitmapFactory.Options?

The BitmapFactory.Options the image should be loaded with.

Public functions

decodeBitmap

fun decodeBitmap(data: ByteArray!): ListenableFuture<Bitmap!>!

Decodes an image from compressed binary data.

loadBitmap

fun loadBitmap(uri: Uri!): ListenableFuture<Bitmap!>!

Loads an image from uri.

supportsMimeType

fun supportsMimeType(mimeType: String!): Boolean

Returns whether the given mimeType is supported.