0

I'm using NOSTRA's Universal Image Loader library and I have caching in memory enabled. It seems that the bitmaps are cached using the URI set in the displayImage() method as the key. As a workaround I created another HashMap that contains the URIs for the images, with a unique id associated with it as the key. The reason for that is the id value is also used to load data in other places, so that value is unique for each image.

So is there a way to change the key for the cached bitmap to something other than the URI?

Wenger
  • 989
  • 2
  • 12
  • 35

2 Answers2

2

Bitmap are cached in memory cache by key pattern [imageUrl]_[width]x[height]. There is no way to change this pattern in current lib version (1.7.0).

nostra13
  • 12,377
  • 3
  • 33
  • 43
  • Thanks. I guess the best method would be to disable caching (it seems like caching in memory isn't working anyway) and just load the bitmap. Then in the onLoadingComplete() I can do the caching and populating the ImageView at the same time. – Wenger Jan 24 '13 at 13:02
  • What does it mean - "it seems like caching in memory isn't working anyway"? – nostra13 Jan 24 '13 at 13:11
  • If I remove .cacheOnDisc() from the display options and leave in .cacheInMemory(), all the images load way slower, which leads me to believe they're still being pulled from the URL. But if I add .cacheOnDisc() back they load fast again. – Wenger Jan 24 '13 at 13:41
  • Because all images can't be cached in memory at the same time. Some images have to be deleted and then they must be downloaded again. – nostra13 Jan 24 '13 at 14:21
0

@ NOSTRA : Can we do like this. instead of passing [imageUrl]_[width]x[height] while generating cachekey we can just pass our unique ID for cache key.

Dinesh.P
  • 61
  • 5