Tecnologia do Blogger.
RSS

Re: [androidbrasil-dev] LruCache não funciona

Resolvido!!
Foi uma bobeira minha!

Estava

mMemoryCache = new LruCache<String, Bitmap>(cacheSize) {
  @Override
  protected int sizeOf(String key, Bitmap bitmap) {
     return bitmap.getByteCount();
  }
}
ao invés de 

mMemoryCache = new LruCache<String, Bitmap>(cacheSize) {
  @Override
  protected int sizeOf(String key, Bitmap bitmap) {
     return bitmap.getByteCount() / 1024;
  }
}

Alguém sabe qual a diferença essa divisão por 1024 faz ?

Abs,


2013/3/7 Gink Labrev <gink.labrev@gmail.com>
Bruno,

Fiz isso:

public void addBitmapToMemoryCache(String key, Bitmap bitmap) {

    if (getBitmapFromMemCache(key) == null) {
        Log.i("TESTE", (bitmap == null) ? "NULL" : "NOT NULL"); // retorna "NOT NULL"
        mMemoryCache.put(key, bitmap);
        Log.i("TESTE", "Tamanho do cache: " + mMemoryCache.size() ); // retorna 0
    }
}

E aparece "NOT NULL" sempre. A única explicação que consigo conceber é que o tamanho da imagem está muito grande para o cache.
Mas não sei como debugar isso ...


2013/3/7 Bruno Albuquerque <bruno.albuquerque@gmail.com>

Você deve estar passando null no lugar do parâmetro bitmap. LRUCache não aceita valores null.




2013/3/7 Gink Labrev <gink.labrev@gmail.com>
Pessoal,

Estou tentando usar o LRU Cache e não funciona.
Notei também que o cache continua com tamanho zero logo após a inserção:

public void addBitmapToMemoryCache(String key, Bitmap bitmap) {
   if (getBitmapFromMemCache(key) == null) {
       mMemoryCache.put(key, bitmap);
       Log.i("TESTE", "Tamanho do cache: " + mMemoryCache.size() ); // retorna 0
   }
}

Alguém sabe explica o que está acontecendo ?

Abs,

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário