public class

ImagePipeline

extends Object
java.lang.Object
   ↳ com.facebook.imagepipeline.core.ImagePipeline

Class Overview

The entry point for the image pipeline.

Summary

Public Constructors
ImagePipeline(ProducerSequenceFactory producerSequenceFactory, Set<RequestListener> requestListeners, Supplier<Boolean> isPrefetchEnabledSupplier, MemoryCache<CacheKeyCloseableImage> bitmapMemoryCache, MemoryCache<CacheKeyPooledByteBuffer> encodedMemoryCache, BufferedDiskCache mainBufferedDiskCache, BufferedDiskCache smallImageBufferedDiskCache, CacheKeyFactory cacheKeyFactory, ThreadHandoffProducerQueue threadHandoffProducerQueue, Supplier<Boolean> suppressBitmapPrefetchingSupplier)
Public Methods
void clearCaches()
Clear all the caches (memory and disk)
void clearDiskCaches()
Clear disk caches
void clearMemoryCaches()
Clear the memory caches
void evictFromCache(Uri uri)

If you have supplied your own cache key factory when configuring the pipeline, this method may not work correctly.

void evictFromDiskCache(Uri uri)

If you have supplied your own cache key factory when configuring the pipeline, this method may not work correctly.

void evictFromDiskCache(ImageRequest imageRequest)
Removes all images with the specified Uri from disk cache.
void evictFromMemoryCache(Uri uri)
Removes all images with the specified Uri from memory cache.
DataSource<CloseableReference<CloseableImage>> fetchDecodedImage(ImageRequest imageRequest, Object callerContext)
Submits a request for execution and returns a DataSource representing the pending decoded image(s).
DataSource<CloseableReference<CloseableImage>> fetchDecodedImage(ImageRequest imageRequest, Object callerContext, ImageRequest.RequestLevel lowestPermittedRequestLevelOnSubmit)
Submits a request for execution and returns a DataSource representing the pending decoded image(s).
DataSource<CloseableReference<PooledByteBuffer>> fetchEncodedImage(ImageRequest imageRequest, Object callerContext)
Submits a request for execution and returns a DataSource representing the pending encoded image(s).
DataSource<CloseableReference<CloseableImage>> fetchImageFromBitmapCache(ImageRequest imageRequest, Object callerContext)
Submits a request for bitmap cache lookup.
MemoryCache<CacheKeyCloseableImage> getBitmapMemoryCache()
CacheKeyFactory getCacheKeyFactory()
Supplier<DataSource<CloseableReference<CloseableImage>>> getDataSourceSupplier(ImageRequest imageRequest, Object callerContext, ImageRequest.RequestLevel requestLevel)
Returns a DataSource supplier that will on get submit the request for execution and return a DataSource representing the pending results of the task.
Supplier<DataSource<CloseableReference<PooledByteBuffer>>> getEncodedImageDataSourceSupplier(ImageRequest imageRequest, Object callerContext)
Returns a DataSource supplier that will on get submit the request for execution and return a DataSource representing the pending results of the task.
boolean isInBitmapMemoryCache(Uri uri)
Returns whether the image is stored in the bitmap memory cache.
boolean isInBitmapMemoryCache(ImageRequest imageRequest)
Returns whether the image is stored in the bitmap memory cache.
DataSource<Boolean> isInDiskCache(Uri uri)
Returns whether the image is stored in the disk cache.
DataSource<Boolean> isInDiskCache(ImageRequest imageRequest)
Returns whether the image is stored in the disk cache.
boolean isInDiskCacheSync(Uri uri, ImageRequest.CacheChoice cacheChoice)
Returns whether the image is stored in the disk cache.
boolean isInDiskCacheSync(ImageRequest imageRequest)
Performs disk cache check synchronously.
boolean isInDiskCacheSync(Uri uri)
Returns whether the image is stored in the disk cache.
boolean isPaused()
void pause()
DataSource<Void> prefetchToBitmapCache(ImageRequest imageRequest, Object callerContext)
Submits a request for prefetching to the bitmap cache.
DataSource<Void> prefetchToDiskCache(ImageRequest imageRequest, Object callerContext, Priority priority)
Submits a request for prefetching to the disk cache.
DataSource<Void> prefetchToDiskCache(ImageRequest imageRequest, Object callerContext)
Submits a request for prefetching to the disk cache with a default priority.
void resume()
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ImagePipeline (ProducerSequenceFactory producerSequenceFactory, Set<RequestListener> requestListeners, Supplier<Boolean> isPrefetchEnabledSupplier, MemoryCache<CacheKeyCloseableImage> bitmapMemoryCache, MemoryCache<CacheKeyPooledByteBuffer> encodedMemoryCache, BufferedDiskCache mainBufferedDiskCache, BufferedDiskCache smallImageBufferedDiskCache, CacheKeyFactory cacheKeyFactory, ThreadHandoffProducerQueue threadHandoffProducerQueue, Supplier<Boolean> suppressBitmapPrefetchingSupplier)

Public Methods

public void clearCaches ()

Clear all the caches (memory and disk)

public void clearDiskCaches ()

Clear disk caches

public void clearMemoryCaches ()

Clear the memory caches

public void evictFromCache (Uri uri)

If you have supplied your own cache key factory when configuring the pipeline, this method may not work correctly. It will only work if the custom factory builds the cache key entirely from the URI. If that is not the case, use evictFromMemoryCache(Uri) and evictFromDiskCache(ImageRequest) separately.

Parameters
uri The uri of the image to evict

public void evictFromDiskCache (Uri uri)

If you have supplied your own cache key factory when configuring the pipeline, this method may not work correctly. It will only work if the custom factory builds the cache key entirely from the URI. If that is not the case, use evictFromDiskCache(ImageRequest).

Parameters
uri The uri of the image to evict

public void evictFromDiskCache (ImageRequest imageRequest)

Removes all images with the specified Uri from disk cache.

Parameters
imageRequest The imageRequest for the image to evict from disk cache

public void evictFromMemoryCache (Uri uri)

Removes all images with the specified Uri from memory cache.

Parameters
uri The uri of the image to evict

public DataSource<CloseableReference<CloseableImage>> fetchDecodedImage (ImageRequest imageRequest, Object callerContext)

Submits a request for execution and returns a DataSource representing the pending decoded image(s).

The returned DataSource must be closed once the client has finished with it.

Parameters
imageRequest the request to submit
callerContext the caller context for image request
Returns
  • a DataSource representing the pending decoded image(s)

public DataSource<CloseableReference<CloseableImage>> fetchDecodedImage (ImageRequest imageRequest, Object callerContext, ImageRequest.RequestLevel lowestPermittedRequestLevelOnSubmit)

Submits a request for execution and returns a DataSource representing the pending decoded image(s).

The returned DataSource must be closed once the client has finished with it.

Parameters
imageRequest the request to submit
callerContext the caller context for image request
lowestPermittedRequestLevelOnSubmit the lowest request level permitted for image request
Returns
  • a DataSource representing the pending decoded image(s)

public DataSource<CloseableReference<PooledByteBuffer>> fetchEncodedImage (ImageRequest imageRequest, Object callerContext)

Submits a request for execution and returns a DataSource representing the pending encoded image(s).

The ResizeOptions in the imageRequest will be ignored for this fetch

The returned DataSource must be closed once the client has finished with it.

Parameters
imageRequest the request to submit
Returns
  • a DataSource representing the pending encoded image(s)

public DataSource<CloseableReference<CloseableImage>> fetchImageFromBitmapCache (ImageRequest imageRequest, Object callerContext)

Submits a request for bitmap cache lookup.

Parameters
imageRequest the request to submit
callerContext the caller context for image request
Returns
  • a DataSource representing the image

public MemoryCache<CacheKeyCloseableImage> getBitmapMemoryCache ()

Returns
  • The Bitmap MemoryCache

public CacheKeyFactory getCacheKeyFactory ()

Returns
  • The CacheKeyFactory implementation used by ImagePipeline

public Supplier<DataSource<CloseableReference<CloseableImage>>> getDataSourceSupplier (ImageRequest imageRequest, Object callerContext, ImageRequest.RequestLevel requestLevel)

Returns a DataSource supplier that will on get submit the request for execution and return a DataSource representing the pending results of the task.

Parameters
imageRequest the request to submit (what to execute).
callerContext the caller context of the caller of data source supplier
requestLevel which level to look down until for the image
Returns
  • a DataSource representing pending results and completion of the request

public Supplier<DataSource<CloseableReference<PooledByteBuffer>>> getEncodedImageDataSourceSupplier (ImageRequest imageRequest, Object callerContext)

Returns a DataSource supplier that will on get submit the request for execution and return a DataSource representing the pending results of the task.

Parameters
imageRequest the request to submit (what to execute).
Returns
  • a DataSource representing pending results and completion of the request

public boolean isInBitmapMemoryCache (Uri uri)

Returns whether the image is stored in the bitmap memory cache.

Parameters
uri the uri for the image to be looked up.
Returns
  • true if the image was found in the bitmap memory cache, false otherwise

public boolean isInBitmapMemoryCache (ImageRequest imageRequest)

Returns whether the image is stored in the bitmap memory cache.

Parameters
imageRequest the imageRequest for the image to be looked up.
Returns
  • true if the image was found in the bitmap memory cache, false otherwise.

public DataSource<Boolean> isInDiskCache (Uri uri)

Returns whether the image is stored in the disk cache.

If you have supplied your own cache key factory when configuring the pipeline, this method may not work correctly. It will only work if the custom factory builds the cache key entirely from the URI. If that is not the case, use isInDiskCache(ImageRequest).

Parameters
uri the uri for the image to be looked up.
Returns
  • true if the image was found in the disk cache, false otherwise.

public DataSource<Boolean> isInDiskCache (ImageRequest imageRequest)

Returns whether the image is stored in the disk cache.

Parameters
imageRequest the imageRequest for the image to be looked up.
Returns
  • true if the image was found in the disk cache, false otherwise.

public boolean isInDiskCacheSync (Uri uri, ImageRequest.CacheChoice cacheChoice)

Returns whether the image is stored in the disk cache. Performs disk cache check synchronously. It is not recommended to use this unless you know what exactly you are doing. Disk cache check is a costly operation, the call will block the caller thread until the cache check is completed.

Parameters
uri the uri for the image to be looked up.
cacheChoice the cacheChoice for the cache to be looked up.
Returns
  • true if the image was found in the disk cache, false otherwise.

public boolean isInDiskCacheSync (ImageRequest imageRequest)

Performs disk cache check synchronously. It is not recommended to use this unless you know what exactly you are doing. Disk cache check is a costly operation, the call will block the caller thread until the cache check is completed.

Parameters
imageRequest the imageRequest for the image to be looked up.
Returns
  • true if the image was found in the disk cache, false otherwise.

public boolean isInDiskCacheSync (Uri uri)

Returns whether the image is stored in the disk cache. Performs disk cache check synchronously. It is not recommended to use this unless you know what exactly you are doing. Disk cache check is a costly operation, the call will block the caller thread until the cache check is completed.

Parameters
uri the uri for the image to be looked up.
Returns
  • true if the image was found in the disk cache, false otherwise.

public boolean isPaused ()

public void pause ()

public DataSource<Void> prefetchToBitmapCache (ImageRequest imageRequest, Object callerContext)

Submits a request for prefetching to the bitmap cache.

Beware that if your network fetcher doesn't support priorities prefetch requests may slow down images which are immediately required on screen.

Parameters
imageRequest the request to submit
Returns
  • a DataSource that can safely be ignored.

public DataSource<Void> prefetchToDiskCache (ImageRequest imageRequest, Object callerContext, Priority priority)

Submits a request for prefetching to the disk cache.

Beware that if your network fetcher doesn't support priorities prefetch requests may slow down images which are immediately required on screen.

Parameters
imageRequest the request to submit
priority custom priority for the fetch
Returns
  • a DataSource that can safely be ignored.

public DataSource<Void> prefetchToDiskCache (ImageRequest imageRequest, Object callerContext)

Submits a request for prefetching to the disk cache with a default priority.

Beware that if your network fetcher doesn't support priorities prefetch requests may slow down images which are immediately required on screen.

Parameters
imageRequest the request to submit
Returns
  • a DataSource that can safely be ignored.

public void resume ()