Search code examples
androiduniversal-image-loader

Quick inquiry about ImageLoader DisplayImage function


I have a question regarding the function DisplayImage from the Universal Image Loader library. If I have a url like "www.myexample.com/image.jpg" and then say:

DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
    .cacheInMemory(true)
    .build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
    .defaultDisplayImageOptions(defaultOptions)
    .build();
ImageLoader.init(config);
String url= "www.myexample.com/image.jpg";
ImageLoader.getInstance().DisplayImage(url, imageviewexpample);

I have the following questions:

  1. Will the imageloader download and save the bitmap in cache first time and then load it from cache next time? or maybe I have to do something in order for it to be loaded from cache next time.
  2. is the "url" argument Im passing the key ImageLoader is using to save it chache? if not, how can I know the key so I can retrieve the image from cache separatedly.
  3. How can I know the answers to these questions without asking here? I mean, is there any documentation like Android API I could have used? prehaps I have to read all the code from the library?

Solution

    1. Yes, with these options (cacheInMemory(true)) images will be kept in a memory cache. UIL can also save them to the device's external storage to 'cache' them. I reckon the cache's size is limited so you might not be guaranteed every image is cached, but that's a guess. See 3.
    2. No. See this question
    3. I mean, is there any documentation like Android API I could have used?

      In this case, yes, that library is very well documented. The project's Github page would be my first place to check for info (also check the issues page). Some other libraries might not be documented as well, then Google and SO will be helpful. Having a look at the source code yourself might or might not be a good options, depending on how much time you have. For most common questions regarding a widely used library like UIL it shouldn't be necessary, yet still can be rewarding.