package vn.tungdx.mediapicker.imageloader;

import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;

import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.nostra13.universalimageloader.core.imageaware.ImageAware;
import com.nostra13.universalimageloader.core.imageaware.ImageViewAware;

import com.buzzcard.brandingtool.R;

/**
 * @author TUNGDX
 */

public class MediaImageLoaderImpl implements MediaImageLoader {

    public MediaImageLoaderImpl(Context context) {
        ImageLoaderConfiguration imageLoaderConfig = new ImageLoaderConfiguration.Builder(context)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .denyCacheImageMultipleSizesInMemory()
                .diskCacheFileNameGenerator(new Md5FileNameGenerator())
                .memoryCacheSizePercentage(30)
                .tasksProcessingOrder(QueueProcessingType.FIFO)
                .writeDebugLogs().threadPoolSize(3)
                .build();

        ImageLoader.getInstance().init(imageLoaderConfig);
    }

    @Override
    public void displayImage(Uri uri, ImageView imageView) {
        DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder()
                .cacheInMemory(true).cacheOnDisk(true)
                .showImageOnLoading(R.color.picker_imageloading)
                .cacheOnDisk(false)
                .considerExifParams(true).resetViewBeforeLoading(true).build();

        ImageAware imageAware = new ImageViewAware(imageView, false);
        ImageLoader.getInstance().displayImage(uri.toString(), imageAware, displayImageOptions);
    }
}
@@ -1510,28 +1510,24 @@
             
-    
 .cacheInMemo
@@ -1538,96 +1538,9 @@
 rue)
-.cacheOnDisk(true)%0A                .showImageOnLoading(R.color.picker_imageloading)%0A    
+%0A
     
@@ -1579,20 +1579,16 @@
         
-    
 .conside
@@ -1604,16 +1604,29 @@
 ms(true)
+%0A            
 .resetVi
@@ -1646,16 +1646,90 @@
 ng(true)
+%0A            .showImageOnLoading(R.color.picker_imageloading)%0A            
 .build()

Refactor construction of DisplayImageOptions