我想显示一个列表视图与很多(远程)图像。我正在尝试使用抽签。排球和位图缓存
排球有些作品,但不够好。在ImageLoader.get凌空具有下面的代码段:
final String cacheKey = getCacheKey(requestUrl, maxWidth, maxHeight);
// Try to look up the request in the cache of remote images.
Bitmap cachedBitmap = mCache.getBitmap(cacheKey);
if (cachedBitmap != null) {
// Return the cached bitmap.
ImageContainer container = new ImageContainer(cachedBitmap, requestUrl, null, null);
imageListener.onResponse(container, true);
return container;
}
然而,getCacheKey产生一个关键是这样的:
/**
* Creates a cache key for use with the L1 cache.
* @param url The URL of the request.
* @param maxWidth The max-width of the output.
* @param maxHeight The max-height of the output.
*/
private static String getCacheKey(String url, int maxWidth, int maxHeight) {
return new StringBuilder(url.length() + 12).append("#W").append(maxWidth)
.append("#H").append(maxHeight).append(url).toString();
}
即它附加一些像的宽度和高度与键“元数据”。
此密钥从来没有产生一击,如果图像不在L1缓存它在线提取。当图像在线获取时,它会保存在磁盘缓存中,但Volley会以URL(仅URL)作为关键字来保存它。
这是预期的行为?我错过了什么吗?
它可能取决于您的回应标题 – njzk2
你知道为什么凌空不会产生热门吗? – iamrelos
您可以使用[droidQuery](http://bit.ly/droidquery)来完成异步请求缓存(Ajax),并且控制缓存更容易(无论是否,以及保留缓存对象多长时间)。 – Phil