use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.
the class DiskCacheReadProducer method produceResults.
public void produceResults(final Consumer<EncodedImage> consumer, final ProducerContext producerContext) {
final ImageRequest imageRequest = producerContext.getImageRequest();
if (!imageRequest.isDiskCacheEnabled()) {
maybeStartInputProducer(consumer, producerContext);
return;
}
producerContext.getListener().onProducerStart(producerContext.getId(), PRODUCER_NAME);
final AtomicBoolean isCancelled = new AtomicBoolean(false);
Task<EncodedImage> diskLookupTask = mDiskCachePolicy.createAndStartCacheReadTask(imageRequest, producerContext.getCallerContext(), isCancelled);
Continuation<EncodedImage, Void> continuation = onFinishDiskReads(consumer, producerContext);
diskLookupTask.continueWith(continuation);
subscribeTaskForRequestCancellation(isCancelled, producerContext);
}
use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.
the class LocalFetchProducer method produceResults.
@Override
public void produceResults(final Consumer<EncodedImage> consumer, final ProducerContext producerContext) {
final ProducerListener listener = producerContext.getListener();
final String requestId = producerContext.getId();
final ImageRequest imageRequest = producerContext.getImageRequest();
final StatefulProducerRunnable cancellableProducerRunnable = new StatefulProducerRunnable<EncodedImage>(consumer, listener, getProducerName(), requestId) {
@Override
protected EncodedImage getResult() throws Exception {
EncodedImage encodedImage = getEncodedImage(imageRequest);
if (encodedImage == null) {
return null;
}
encodedImage.parseMetaData();
return encodedImage;
}
@Override
protected void disposeResult(EncodedImage result) {
EncodedImage.closeSafely(result);
}
};
producerContext.addCallbacks(new BaseProducerContextCallbacks() {
@Override
public void onCancellationRequested() {
cancellableProducerRunnable.cancel();
}
});
mExecutor.execute(cancellableProducerRunnable);
}
use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.
the class DraweeRotationFragment method setRotationOptions.
private void setRotationOptions(RotationOptions rotationOptions) {
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(URI).setRotationOptions(rotationOptions).build();
mSimpleDraweeView.setController(Fresco.newDraweeControllerBuilder().setImageRequest(imageRequest).build());
}
use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.
the class ImagePipelineNotificationFragment method createNotification.
private void createNotification() {
final ImagePipeline imagePipeline = Fresco.getImagePipeline();
final ImageRequest imageRequest = ImageRequest.fromUri(URI);
final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, null);
dataSource.subscribe(new BaseBitmapDataSubscriber() {
@Override
protected void onNewResultImpl(Bitmap bitmap) {
displayNotification(bitmap);
}
@Override
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
showToastText("Failed to fetch image directly: " + dataSource.getFailureCause());
// In general, failing to fetch the image should not keep us from displaying the
// notification. We proceed without the bitmap.
displayNotification(null);
}
}, UiThreadImmediateExecutorService.getInstance());
}
use of com.facebook.imagepipeline.request.ImageRequest in project ride-read-android by Ride-Read.
the class ImgLoader method getDiscCacheFile.
public File getDiscCacheFile(String url) {
ImageRequest imageRequest = ImageRequest.fromUri(Uri.parse(url));
CacheKey cacheKey = Utils.getAppContext().getImagePipeLineConfig().getCacheKeyFactory().getEncodedCacheKey(imageRequest, null);
FileBinaryResource fileBinaryResource = (FileBinaryResource) Fresco.getImagePipelineFactory().getMainDiskStorageCache().getResource(cacheKey);
if (fileBinaryResource == null) {
return null;
} else {
return fileBinaryResource.getFile();
}
}
Aggregations