gpt4 book ai didi

android - 通过 Intent 快速共享 Fresco 缓存图像

转载 作者:行者123 更新时间:2023-11-30 01:39:04 26 4
gpt4 key购买 nike

想要从本地存储共享 Fresco 缓存图像的过程更快更快捷

fresco returning bitmap with callback some time it takes time for fetching image.

Not able to share direct bitmap via intent needs for store image temp first and then share file path URI of image.

            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();
}

最佳答案

在构建上面的 ImageRequest 时,添加以下行:

.setLowestPermittedRequestLevel(BITMAP_MEMORY_CACHE)

然后您可以假设数据源会立即返回,您可以调用 DataSource.hasResult()DataSource.getResult() 来立即获取您的位图。

你还是要按照rules for closeable references .

关于android - 通过 Intent 快速共享 Fresco 缓存图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34744431/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com