我想顯示一個列表視圖與很多(遠程)圖像。我正在嘗試使用抽籤。排球和位圖緩存
排球有些作品,但不夠好。在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