Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何提高facebook fresco ImageRequest缓存图像位图加载的速度?_Android_Android Bitmap_Fresco - Fatal编程技术网

Android 如何提高facebook fresco ImageRequest缓存图像位图加载的速度?

Android 如何提高facebook fresco ImageRequest缓存图像位图加载的速度?,android,android-bitmap,fresco,Android,Android Bitmap,Fresco,我正在尝试从一个按钮点击事件后的片段中获取壁画缓存图像,以在whatsapp中共享图像位图!!不幸的是,它的速度非常慢,点击共享按钮2,3次代码工作!!我正在寻找更好的解决方案 ImageRequest imageRequest = ImageRequestBuilder .newBuilderWithSource(Uri.parse("http://example.com/test,jpg"))// disck cached

我正在尝试从一个按钮点击事件后的片段中获取壁画缓存图像,以在whatsapp中共享图像位图!!不幸的是,它的速度非常慢,点击共享按钮2,3次代码工作!!我正在寻找更好的解决方案

 ImageRequest imageRequest = ImageRequestBuilder
                            .newBuilderWithSource(Uri.parse("http://example.com/test,jpg"))// disck cached 
                            .setRequestPriority(com.facebook.imagepipeline.common.Priority.HIGH)
                            .setLowestPermittedRequestLevel(ImageRequest.RequestLevel.DISK_CACHE)
                            .build();

                    //  .setRequestPriority(Priority.HIGH)

                    DataSource<CloseableReference<CloseableImage>> dataSource =
                            imagePipeline.fetchDecodedImage(imageRequest, this);

                    try {
                        dataSource.subscribe(new BaseBitmapDataSubscriber() {
                            @Override
                            public void onNewResultImpl(@Nullable Bitmap bitmap) {
                                if (bitmap == null) {
                                    Log.d(TAG, "Bitmap data source returned success, but bitmap null.");
                                    return;
                                }

                                sharewithwhatsappBitmap(bitmap);
                                // The bitmap provided to this method is only guaranteed to be around
                                // for the lifespan of this method. The image pipeline frees the
                                // bitmap's memory after this method has completed.
                                //
                                // This is fine when passing the bitmap to a system process as
                                // Android automatically creates a copy.
                                //
                                // If you need to keep the bitmap around, look into using a
                                // BaseDataSubscriber instead of a BaseBitmapDataSubscriber.
                            }

                            @Override
                            public void onFailureImpl(DataSource dataSource) {
                                // No cleanup required here
                                Log.d(TAG, "Bitmap data source onFailureImpl");
                            }
                        }, CallerThreadExecutor.getInstance());
                    } finally {
                        if (dataSource != null) {
                            dataSource.close();
                        }
                    }
第一次调用位图时记录:

 v/unknown:AbstractDraweeController: controller 2a7f5b0e null -> 15: initialize
  V/unknown:AbstractDraweeController: controller 2a7f5b0e 15: setHierarchy: com.facebook.drawee.generic.GenericDraweeHierarchy@20cc392f

这是获取位图的推荐方法。你的形象有多大?什么文件类型?我猜这是一个巨大的图像,需要一些时间从磁盘加载,解码,…这是一个大小为150kb的JPEG图像,规格为1150x782!!!我没有找到解决方案,以获得可从回收视图显示的图像项目,我使用抽屉控制器!!!!!我也在寻找一个解决方案,我可以在碎片中加载缓存。好的,这样应该会更快。如果您使用抽屉显示位图,然后使用上面的代码,我们只加载一次位图,将其缓存,然后重新使用,因此这应该非常快。目前有多慢?也许位图处理代码(
sharewithwhatsappBitmap
)会使它变慢?我们不建议从drawable中获取位图,因为受票人实现可能会改变,或者位图可能不同(例如,缩小、后处理、四舍五入…)。您可以查看
GenericDraweeHierarchy
以了解如何创建可绘制文件。onnerResultImpl回调很慢,第二次可以随机运行!!我正在使用这个逻辑recyclerview,但是在片段中而不是在适配器中访问缓存,以直接从SimpleDraweView获取可绘制文件!!我将查看GenericDraweeHierarchy Thanks我必须用上面提到的代码“PooledByteBuffer”做任何事情??这是获得位图的推荐方法。你的形象有多大?什么文件类型?我猜这是一个巨大的图像,需要一些时间从磁盘加载,解码,…这是一个大小为150kb的JPEG图像,规格为1150x782!!!我没有找到解决方案,以获得可从回收视图显示的图像项目,我使用抽屉控制器!!!!!我也在寻找一个解决方案,我可以在碎片中加载缓存。好的,这样应该会更快。如果您使用抽屉显示位图,然后使用上面的代码,我们只加载一次位图,将其缓存,然后重新使用,因此这应该非常快。目前有多慢?也许位图处理代码(
sharewithwhatsappBitmap
)会使它变慢?我们不建议从drawable中获取位图,因为受票人实现可能会改变,或者位图可能不同(例如,缩小、后处理、四舍五入…)。您可以查看
GenericDraweeHierarchy
以了解如何创建可绘制文件。onnerResultImpl回调很慢,第二次可以随机运行!!我正在使用这个逻辑recyclerview,但是在片段中而不是在适配器中访问缓存,以直接从SimpleDraweView获取可绘制文件!!我将查看GenericDraweeHierarchy Thanks我必须用上面提到的代码来处理“PooledByteBuffer”吗??
 v/unknown:AbstractDraweeController: controller 2a7f5b0e null -> 15: initialize
  V/unknown:AbstractDraweeController: controller 2a7f5b0e 15: setHierarchy: com.facebook.drawee.generic.GenericDraweeHierarchy@20cc392f