Removed bitmaps on LruCache is not checked if it is being used #41

Open
sigelinde opened this Issue Jan 26, 2014 · 1 comment

Comments

Projects
None yet
2 participants

In BitmapMemoryLruCache#getBitmapFromRemoved method, we judge if the bitmap is used by following:
value != null && value.isBitmapValid() && value.isBitmapMutable()
This is not enough and should be added following:
&& !value.isBeingDisplayed() && !value.isReferencedByCache()

This is because LruCache#entryRemoved is not called on the bitmap is no more used but called on the last method call of LruCache#get for the bitmap is in the distant past.

I met this issue when using ListView on ViewPager. When I scrolled ListView enough and changed page, bitmaps on another pages are not correct.

elroid commented Feb 19, 2014

I second the need for "&& !value.isBeingDisplayed()". If you have CacheableImageViews that are always visible, and CacheableImageViews in a list view as well, the bitmap of the statically visible image will often get recycled incorrectly (and start showing one of the images from the list).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment