【发布时间】:2018-06-21 07:56:55
【问题描述】:
想要更快更快速地共享 fresco 缓存图像表单 loacl 存储
fresco 返回带有回调的位图需要一些时间来获取图像。
无法通过 Intent 共享直接位图,需要先存储图像临时然后共享图像的文件路径 URI。
ImageRequest imageRequest = ImageRequestBuilder
.newBuilderWithSource(httpUri(article.getImage())).setAutoRotateEnabled(true)
.build();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
final DataSource<CloseableReference<CloseableImage>>
dataSource = imagePipeline.fetchDecodedImage(imageRequest, view.getContext());
dataSource.subscribe(new BaseBitmapDataSubscriber() {
@Override
public void onNewResultImpl(@Nullable Bitmap bitmap) {
if (dataSource.isFinished() && bitmap != null) {
String pathofBmp = MediaStore.Images.Media.insertImage(view.getContext().getContentResolver(), bitmap, "APp", null);
Uri bmpUri = Uri.parse(pathofBmp);
ShareCompat.IntentBuilder.from((Activity) parent.getContext())
.setChooserTitle(R.string.share)
.setText(format("%s via App %s", title, ""))
.setSubject(format("%s via App", title))
.setStream(bmpUri)
.setType("image/jpeg")
.startChooser();
dataSource.close();
}
dataSource.close();
}
【问题讨论】:
-
问题到底是什么?