// Path: library-lis/src/main/java/com/cocolover2/lis/utils/ImageCache.java
// public class ImageCache {
//     private static LruCache<String, Bitmap> mCache;
// 
//     private ImageCache() {
//     }
// 
//     public static LruCache<String, Bitmap> getInstance() {
//         if (mCache == null)
//             synchronized (ImageCache.class) {
//                 if (mCache == null)
//                     mCache = new LruCache<String, Bitmap>((int) Runtime.getRuntime().maxMemory() / 8) {
//                         @Override
//                         protected int sizeOf(String key, Bitmap value) {
//                             if (Build.VERSION.SDK_INT > 12)
//                                 return value.getByteCount();
//                             else
//                                 return value.getRowBytes() * value.getHeight();
//                         }
//                     };
//             }
//         return mCache;
//     }
// }
// 
// Path: library-lis/src/main/java/com/cocolover2/lis/utils/ImageUtils.java
// public class ImageUtils {
//     private ImageUtils() {
//         throw new UnsupportedOperationException("cannot be instantiated");
//     }
// 
//     /**
//      * 压缩图片的像素
//      *
//      * @param path
//      * @param requestWidth
//      * @param requestHeight
//      * @return
//      */
//     public static Bitmap compressImgBySize(String path, int requestWidth, int requestHeight) {
//         if (null == path || TextUtils.isEmpty(path) || !new File(path).exists())
//             return null;
//         //第一次解析图片的时候将inJustDecodeBounds设置为true,来获取图片的大小
//         BitmapFactory.Options options = new BitmapFactory.Options();
//         options.inJustDecodeBounds = true;
//         BitmapFactory.decodeFile(path, options);
//         options.inSampleSize = calculateInSampleSize(options, requestWidth, requestHeight);
//         options.inJustDecodeBounds = false;
//         return BitmapFactory.decodeFile(path, options);
//     }
// 
//     private static int calculateInSampleSize(BitmapFactory.Options options, int requestWidth, int requestHeight) {
//         int width = options.outWidth;
//         int height = options.outHeight;
//         int inSampleSize = 1;
//         if (width > requestWidth || height > requestHeight) {
//             final int heightRatio = Math.round((float) height / (float) requestHeight);
//             final int widthRatio = Math.round((float) width / (float) requestWidth);
//             inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
//         }
//         return inSampleSize;
//     }
// }


import android.graphics.Bitmap;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.widget.AbsListView;
import android.widget.ImageView;
import com.cocolover2.lis.utils.ImageCache;
import com.cocolover2.lis.utils.ImageUtils;
import java.util.LinkedList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
     * @param imageView
     */
    public void loadImage(final String path, final ImageView imageView, int defaultImgId) {
        if (isScrolling) {
            if (defaultImgId != 0)
                imageView.setImageResource(defaultImgId);
        }

        if (isFling) {
            return;
        }
        // set tag
        imageView.setTag(path);
        // UI线程
        if (mHandler == null) {
            mHandler = new WeakHandler();
        }
        Bitmap bm = getBitmapFromLruCache(path);
        if (bm != null) {
            ImgBeanHolder holder = new ImgBeanHolder();
            holder.bitmap = bm;
            holder.imageView = imageView;
            holder.path = path;
            Message message = Message.obtain();
            message.obj = holder;
            mHandler.sendMessage(message);
        } else {
            addTask(new Runnable() {
                @Override
                public void run() {
// Path: library-lis/src/main/java/com/cocolover2/lis/utils/ImageCache.java
// public class ImageCache {
//     private static LruCache<String, Bitmap> mCache;
// 
//     private ImageCache() {
//     }
// 
//     public static LruCache<String, Bitmap> getInstance() {
//         if (mCache == null)
//             synchronized (ImageCache.class) {
//                 if (mCache == null)
//                     mCache = new LruCache<String, Bitmap>((int) Runtime.getRuntime().maxMemory() / 8) {
//                         @Override
//                         protected int sizeOf(String key, Bitmap value) {
//                             if (Build.VERSION.SDK_INT > 12)
//                                 return value.getByteCount();
//                             else
//                                 return value.getRowBytes() * value.getHeight();
//                         }
//                     };
//             }
//         return mCache;
//     }
// }
// 
// Path: library-lis/src/main/java/com/cocolover2/lis/utils/ImageUtils.java
// public class ImageUtils {
//     private ImageUtils() {
//         throw new UnsupportedOperationException("cannot be instantiated");
//     }
// 
//     /**
//      * 压缩图片的像素
//      *
//      * @param path
//      * @param requestWidth
//      * @param requestHeight
//      * @return
//      */
//     public static Bitmap compressImgBySize(String path, int requestWidth, int requestHeight) {
//         if (null == path || TextUtils.isEmpty(path) || !new File(path).exists())
//             return null;
//         //第一次解析图片的时候将inJustDecodeBounds设置为true,来获取图片的大小
//         BitmapFactory.Options options = new BitmapFactory.Options();
//         options.inJustDecodeBounds = true;
//         BitmapFactory.decodeFile(path, options);
//         options.inSampleSize = calculateInSampleSize(options, requestWidth, requestHeight);
//         options.inJustDecodeBounds = false;
//         return BitmapFactory.decodeFile(path, options);
//     }
// 
//     private static int calculateInSampleSize(BitmapFactory.Options options, int requestWidth, int requestHeight) {
//         int width = options.outWidth;
//         int height = options.outHeight;
//         int inSampleSize = 1;
//         if (width > requestWidth || height > requestHeight) {
//             final int heightRatio = Math.round((float) height / (float) requestHeight);
//             final int widthRatio = Math.round((float) width / (float) requestWidth);
//             inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
//         }
//         return inSampleSize;
//     }
// }


// Path: library-lis/src/main/java/com/cocolover2/lis/LocalImageLoader.java
import android.graphics.Bitmap;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.widget.AbsListView;
import android.widget.ImageView;
import com.cocolover2.lis.utils.ImageCache;
import com.cocolover2.lis.utils.ImageUtils;
import java.util.LinkedList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;

     * @param imageView
     */
    public void loadImage(final String path, final ImageView imageView, int defaultImgId) {
        if (isScrolling) {
            if (defaultImgId != 0)
                imageView.setImageResource(defaultImgId);
        }

        if (isFling) {
            return;
        }
        // set tag
        imageView.setTag(path);
        // UI线程
        if (mHandler == null) {
            mHandler = new WeakHandler();
        }
        Bitmap bm = getBitmapFromLruCache(path);
        if (bm != null) {
            ImgBeanHolder holder = new ImgBeanHolder();
            holder.bitmap = bm;
            holder.imageView = imageView;
            holder.path = path;
            Message message = Message.obtain();
            message.obj = holder;
            mHandler.sendMessage(message);
        } else {
            addTask(new Runnable() {
                @Override
                public void run() {
                    Bitmap bm = ImageUtils.compressImgBySize(path, imgWidth,