代码语言:javascript复制
// To get image using Fresco
ImageRequest imageRequest = ImageRequestBuilder
.newBuilderWithSource(Uri.parse(ImgUrl))
.setProgressiveRenderingEnabled(true)
.build();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
DataSource<CloseableReference<CloseableImage>>
dataSource = imagePipeline.fetchDecodedImage(imageRequest,this);
dataSource.subscribe(new BaseBitmapDataSubscriber() {
@Override
public void onNewResultImpl(@Nullable Bitmap bitmap) {
// You can use the bitmap in only limited ways
// No need to do any cleanup.
imageView.setImageBitmap(bitmap);
}
@Override
public void onFailureImpl(DataSource dataSource) {
// No cleanup required here.
}
}, CallerThreadExecutor.getInstance());