Created
November 29, 2016 15:06
-
-
Save chethann/8af732490f0d1250e1bd1cb23ab8aedc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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