【问题标题】:UIL Custom Downloader doesn't use content from cacheUIL 自定义下载器不使用缓存中的内容
【发布时间】:2014-01-10 11:03:49
【问题描述】:

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

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}

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

【问题讨论】:

  • 您是否在DisplayImageOptions 中启用了缓存?
  • 这是我的配置:DisplayImageOptions opts = new DisplayImageOptions.Builder() .extraForDownloader(new ImageSocketDownloaderExtra(request, actionId)) .considerExifParams(false) .cacheInMemory() .build();

标签: android image imageview universal-image-loader


【解决方案1】:

正如我在日志中看到的,之前的任务在图像加载期间被取消。所以图像加载被中断,因为 ImageView 被重用了。看来你滚动列表和icon-1 走出屏幕。然后滚动,icon-1 应该会再次显示,但它没有缓存在内存中,因为它没有完全下载(任务被中断)。所以 ImageLoader 再次开始加载。 所以没关系。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    • 2014-12-31
    • 1970-01-01
    • 2013-11-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多