Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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 UIL自定义下载程序不使用缓存中的内容_Android_Image_Imageview_Universal Image Loader - Fatal编程技术网

Android UIL自定义下载程序不使用缓存中的内容

Android UIL自定义下载程序不使用缓存中的内容,android,image,imageview,universal-image-loader,Android,Image,Imageview,Universal Image Loader,我已经实现了自己的下载程序,但他似乎没有使用他已经检索到的缓存中的图像。我的初始化: private void initImageLoader() { ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this) .imageDownloader(new SocketDownloader(this)) .memoryCacheSizePercenta

我已经实现了自己的下载程序,但他似乎没有使用他已经检索到的缓存中的图像。我的初始化:

private void initImageLoader() {
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
            .imageDownloader(new SocketDownloader(this))
            .memoryCacheSizePercentage(25)
            .writeDebugLogs()
            .build();
    ImageLoader.getInstance().init(config);
}
以下是我在logcat中发现的内容:

01-10 11:47:26.899: D/ImageLoader(2345): Start display image task [socket://images/test-
icon-1.png_53x53]
01-10 11:47:26.899: D/ImageLoader(2345): Load image from network [socket://images/test-
icon-1.png_53x53]
01-10 11:47:26.899: D/Request(2345): request {"path":"images\/test-
icon-1.png","action":"getimage","actionid":0}
01-10 11:47:28.719: D/ImageLoader(2345): Subsample original image (200x200) to 100x100 
(scale = 2) [socket://images/test-icon-1.png_53x53]
01-10 11:47:28.729: D/ImageLoader(2345): ImageAware is reused for another image. Task is 
cancelled. [socket://images/test-icon-1.png_53x53]
01-10 11:47:28.839: D/ImageLoader(2345): Start display image task [socket://images/test-
icon-1.png_53x53]
01-10 11:47:28.839: D/ImageLoader(2345): Load image from network [socket://images/test-
icon-1.png_53x53]
01-10 11:47:28.839: D/Request(2345): request {"path":"images\/test-
icon-1.png","action":"getimage","actionid":0}

运行在Nexus7上,它实际上应该有足够的堆来执行2个映像的操作。感谢您回复有用的提示。

正如我在日志中看到的,上一个任务在图像加载过程中被取消。因此图像加载被中断,因为ImageView被重用。看起来你们滚动列表,图标1从屏幕上消失了。然后您滚动,图标1应该再次显示,但它并没有缓存在内存中,因为它并没有完全下载。任务被中断。所以ImageLoader再次开始加载。 所以没关系


顺便说一句,我也建议启用磁盘缓存。它可以防止重复下载。

是否在DisplayImageOptions中启用缓存?这是我的配置:DisplayImageOptions opts=new DisplayImageOptions.Builder.extraForDownloadernew ImageSocketDownloaderExtrarequest,actionId.considerExifParamsfalse.cacheInMemory.build;