Skip to content

Instantly share code, notes, and snippets.

@chethann
Created November 29, 2016 15:06
Show Gist options
  • Save chethann/8af732490f0d1250e1bd1cb23ab8aedc to your computer and use it in GitHub Desktop.
Save chethann/8af732490f0d1250e1bd1cb23ab8aedc to your computer and use it in GitHub Desktop.
private static void downloadBitmap(ImageRequest imageRequest, Context context, final IBitmapDownloader iBitmapDownloader) {
DataSource<CloseableReference<CloseableImage>> dataSourceImage = Fresco.getImagePipeline().fetchDecodedImage(imageRequest, context);
DataSubscriber<CloseableReference<CloseableImage>> dataSubscriberImage = new BaseDataSubscriber<CloseableReference<CloseableImage>>() {
@Override
public void onNewResultImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
CloseableReference<CloseableImage> imageReference = dataSource.getResult();
if (imageReference != null) {
iBitmapDownloader.onSuccess(imageReference);
}
else{
iBitmapDownloader.onFailure(null);
}
}
@Override
public void onFailureImpl(DataSource dataSource) {
iBitmapDownloader.onFailure(dataSource);
}
};
dataSourceImage.subscribe(dataSubscriberImage, CallerThreadExecutor.getInstance());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment