Sto tentando di visualizzare un listview con molte (remote) immagini. Sto cercando di usare la pallavolo per il compito.Memorizzazione nella cache di volley e bitmap
Volley funziona in qualche modo, ma non abbastanza. In ImageLoader.get volley ha il seguente pezzo di codice:
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;
}
Tuttavia, getCacheKey produce una chiave simile:
/**
* 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();
}
cioè che aggiunge qualche "metadati" come larghezza e l'altezza alla chiave.
Questa chiave mai produce un hit e se l'immagine non è nella cache L1 viene recuperata online. Quando l'immagine viene recuperata online, viene salvata nella cache del disco ma Volley la salva con l'URL (e solo l'URL) come chiave.
È questo comportamento previsto? Mi sto perdendo qualcosa?
potrebbe dipendere dalle intestazioni dalla risposta – njzk2
hai capito perché la scarica non produce un successo? – iamrelos
È possibile utilizzare [droidQuery] (http://bit.ly/droidquery) per completare le richieste restanti asincrone (Ajax) e controllare la cache più facilmente (indipendentemente dal fatto che sia e per quanto tempo conservare un oggetto memorizzato nella cache). – Phil