Closed curioustechizen closed 11 years ago
How do you plan on letting each Drawable cache itself?
@chrisbanes I'm not sure I understand your question. The thing is there is a case where I don't have a drawable at all. I have a custom view that extends View
. In the constructor, I am currently using BitmapFactory.decode
to decode a resource from the drawable-*dpi
folders. This returns a Bitmap
object which I then pass in to canvas.drawBitmap()
in my onDraw()
method.
Probably the CacheableBitmapWrapper
might have been useful. But it has been removed now. Is there a specific reason it was removed?
CacheableBitmapDrawable
replaced CacheableBitmapWrapper
. It does exactly the same job, except that ImageView, etc, can use CacheableBitmapDrawable
without having to unwrap.
My question was basically asking something can't cache itself. There needs to be something 'higher' level which decides what is cached, and what is evicted.
You can still use the LruCache, just use decode your resource and then put it in the cache via:
BitmapLruCache.put(String, Bitmap)
Ah okay .. I see your point now. Thanks.
Is there a specific reason that
BitmapLruCache
caches theBitmapDrawable
s as opposed to theBitmap
objects themselves?I want to use this library for caching decoded resources that will eventually be drawn on canvas (
canvas.drawBitmap()
). My customView
does not have a drawable to speak of. I could still use theCacheableBitmapDrawable
just for the cache (and then extract out theBitmap
from the drawable that I get from the cache), but this does not seem clean.