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);
}
Aggregations