Search in sources :

Example 1 with BufferedDiskCache

use of com.facebook.imagepipeline.cache.BufferedDiskCache in project fresco by facebook.

the class MediaVariationsFallbackProducer method attemptCacheReadForVariant.

private Task attemptCacheReadForVariant(final Consumer<EncodedImage> consumer, final ProducerContext producerContext, ImageRequest imageRequest, MediaVariations mediaVariations, List<MediaVariations.Variant> sortedVariants, int index, AtomicBoolean isCancelled) {
    final MediaVariations.Variant variant = sortedVariants.get(index);
    final CacheKey cacheKey = mCacheKeyFactory.getEncodedCacheKey(imageRequest, variant.getUri(), producerContext.getCallerContext());
    final ImageRequest.CacheChoice cacheChoice;
    if (variant.getCacheChoice() == null) {
        cacheChoice = imageRequest.getCacheChoice();
    } else {
        cacheChoice = variant.getCacheChoice();
    }
    final BufferedDiskCache preferredCache = cacheChoice == ImageRequest.CacheChoice.SMALL ? mSmallImageBufferedDiskCache : mDefaultBufferedDiskCache;
    Task<EncodedImage> readTask = preferredCache.get(cacheKey, isCancelled);
    Continuation<EncodedImage, Void> continuation = onFinishDiskReads(consumer, producerContext, imageRequest, mediaVariations, sortedVariants, index, isCancelled);
    return readTask.continueWith(continuation);
}
Also used : BufferedDiskCache(com.facebook.imagepipeline.cache.BufferedDiskCache) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) EncodedImage(com.facebook.imagepipeline.image.EncodedImage) CacheKey(com.facebook.cache.common.CacheKey) MediaVariations(com.facebook.imagepipeline.request.MediaVariations)

Aggregations

CacheKey (com.facebook.cache.common.CacheKey)1 BufferedDiskCache (com.facebook.imagepipeline.cache.BufferedDiskCache)1 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)1 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)1 MediaVariations (com.facebook.imagepipeline.request.MediaVariations)1