-2

I'm showing a list of users in a recycleview/listview.
Each item shows user image and other information. I'm having user image urls as

ThumbNail : www.image_storage_server.com/thumbs/userid 
FullImage : www.image_storage_server.com/images/userid


I want to show this thumbnails in list item. It should work as below

  1. Download the image and show it in list.
  2. Cache the downloaded image. And use it while loading the image.
  3. If there's no network, show the cached image.

Basically i want to load the thumbnails every time, if there's network.


When user clicks on list item, I want to show user's full image.
And while loading , i want to show the cached thumbnail as the default image.

I'm currently using universal-image-loader but i didn't find a way to achieve this.
How to achieve this ?
Is there any other library which provides this kind of functionality ?

Below is my code.

//Initializing imageloader in application's oncreate
DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageForEmptyUri(R.drawable.avatar)
                .showImageOnFail(R.drawable.avatar)
                .cacheInMemory(true) // default
                .cacheOnDisk(true) // default
                .build();

        ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
        config.threadPriority(Thread.NORM_PRIORITY - 2);
        config.denyCacheImageMultipleSizesInMemory();
        config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
        config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
        config.tasksProcessingOrder(QueueProcessingType.LIFO);
        config.defaultDisplayImageOptions(options);

        // Initialize ImageLoader with configuration.
        ImageLoader.getInstance().init(config.build());


Loading image using image loader in RecycleAdapter

ImageLoader.getInstance().displayImage(user.getThumbnailUrl(), vh.avatarIV);
Shree
  • 1,061
  • 3
  • 11
  • 25
  • Post some code, what you have tried till now? – Nigam Patro Nov 25 '16 at 07:08
  • Many app needs to implement this kind of functionality. So yes there are many libraries available on Github. One of the most popular and very nicely implemented library is Picasso. http://square.github.io/picasso/ – Dhrumil Patel Nov 25 '16 at 07:09

1 Answers1

1

Try using Glide (https://github.com/bumptech/glide)

Its very fast and easy to implement over other image loading libraries that I used.

Prashant
  • 112
  • 8