sauravtom / android-query

Automatically exported from code.google.com/p/android-query
0 stars 0 forks source link

Don't Load Image if Cached Version is Found #91

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'm rendering images in a list, with the following, where $ is the AQuery 
instance, and targetUrl is the url I'd like to load the image from:

$.id( holder.contentImage ).image( targetUrl, true, true, 0, 0, null, 
AQuery.FADE_IN, AQuery.RATIO_PRESERVE );

My issue is that the list renders once, with the cached image, but then 
re-downloads it from the web, and flickers as it re-renders the exact same 
image. 

Is it possible to configure it to use the image if it's in the cache and NOT 
load it from the server, unless it isn't in the cache? 

Original issue reported on code.google.com by lifeCode...@gmail.com on 9 Oct 2012 at 9:53

GoogleCodeExporter commented 8 years ago
Are you sure it's loading from server? If an image is too big it skips the 
memory and use file cache.

To allow bigger image to be cached in memory, use the setPixelLimit function:

http://code.google.com/p/android-query/wiki/ImageLoading#Configuration

Original comment by tinyeeliu@gmail.com on 19 Oct 2012 at 11:58

GoogleCodeExporter commented 8 years ago
AFAIK, aquery DOES use the cached files first, but it doesn't check if same 
image already was loaded into given image view. Which, in turn, causes 
flickering when aquery is used in listadapter binder.
In our application we use this trick to avoid flicker - 
if (imageObject.getTag(AQuery.TAG_URL) == null || 
!(imageObject.getTag(AQuery.TAG_URL).equals(imageUrl))) {
                AQuery aQuery = new AQuery(imageObject);
                aQuery.image(imageUrl, true, true, imageObject.getWidth(), 0, null, R.anim.fade_in);
            }

we check imageview tag and fade in loaded images. looks great.

Original comment by eugene.k...@gmail.com on 2 Jul 2014 at 7:13