// Path: restvolley/src/main/java/com/hujiang/restvolley/MD5Utils.java
// public class MD5Utils {
// 
//     private static final int HEX_FF = 0xFF;
// 
//     /**
//      *
//      * @param key for disk.
//      * @return hash key.
//      */
//     public static String hashKeyForDisk(String key) {
//         String cacheKey;
//         try {
//             final MessageDigest mDigest = MessageDigest.getInstance("MD5");
//             mDigest.update(key.getBytes());
//             cacheKey = bytesToHexString(mDigest.digest());
//         } catch (NoSuchAlgorithmException e) {
//             cacheKey = String.valueOf(key.hashCode());
//         }
//         return cacheKey;
//     }
// 
//     private static String bytesToHexString(byte[] bytes) {
//         StringBuilder sb = new StringBuilder();
//         for (int i = 0; i < bytes.length; i++) {
//             String hex = Integer.toHexString(HEX_FF & bytes[i]);
//             if (hex.length() == 1) {
//                 sb.append('0');
//             }
//             sb.append(hex);
//         }
//         return sb.toString();
//     }
// 
// }
// 
// Path: restvolley/src/main/java/com/hujiang/restvolley/compat/StreamBasedNetworkResponse.java
// public class StreamBasedNetworkResponse extends NetworkResponse {
// 
//     /** Raw data inputStream from this response. */
//     public final InputStream inputStream;
//     public final long contentLength;
// 
//     public StreamBasedNetworkResponse(int statusCode, InputStream inputStream, long contentLength, Map<String, String> headers, boolean notModified, long networkTimeMs) {
//         super(statusCode, null, headers, notModified, networkTimeMs);
//         this.inputStream = inputStream;
//         this.contentLength = contentLength;
//     }
// 
//     public StreamBasedNetworkResponse(int statusCode, InputStream inputStream, long contentLength, Map<String, String> headers, boolean notModified) {
//         super(statusCode, null, headers, notModified);
//         this.inputStream = inputStream;
//         this.contentLength = contentLength;
//     }
// 
//     public StreamBasedNetworkResponse(InputStream inputStream, long contentLength) {
//         super(null);
//         this.inputStream = inputStream;
//         this.contentLength = contentLength;
//     }
// 
//     public StreamBasedNetworkResponse(InputStream inputStream, long contentLength, Map<String, String> headers) {
//         super(null, headers);
//         this.inputStream = inputStream;
//         this.contentLength = contentLength;
//     }
// 
//     public StreamBasedNetworkResponse(int statusCode, byte[] data, Map<String, String> headers, boolean notModified, long networkTimeMs) {
//         super(statusCode, data, headers, notModified, networkTimeMs);
//         this.inputStream = null;
//         this.contentLength = data != null ? data.length : 0;
//     }
// 
//     public StreamBasedNetworkResponse(int statusCode, byte[] data, Map<String, String> headers, boolean notModified) {
//         super(statusCode, data, headers, notModified);
//         this.inputStream = null;
//         this.contentLength = data != null ? data.length : 0;
//     }
// 
//     public StreamBasedNetworkResponse(byte[] data) {
//         super(data);
//         this.inputStream = null;
//         this.contentLength = data != null ? data.length : 0;
//     }
// 
//     public StreamBasedNetworkResponse(byte[] data, Map<String, String> headers) {
//         super(data, headers);
//         this.inputStream = null;
//         this.contentLength = data != null ? data.length : 0;
//     }
// }
// 
// Path: restvolley/src/main/java/com/hujiang/restvolley/image/ImageProcessor.java
// public static final int BYTE_IN_PIX = 4;


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.widget.ImageView;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyLog;
import com.hujiang.restvolley.MD5Utils;
import com.hujiang.restvolley.compat.StreamBasedNetworkResponse;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import static com.hujiang.restvolley.image.ImageProcessor.BYTE_IN_PIX;

        BufferedOutputStream bitmapOutputStream = null;
        try {
            bitmapOutputStream = new BufferedOutputStream(new FileOutputStream(bitmapCache));
            byte[] buffer = new byte[BUFFER_SIZE];
            int len;
            while ((len = bitmapStream.read(buffer)) != -1) {
                bitmapOutputStream.write(buffer, 0, len);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (bitmapStream != null) {
                    bitmapStream.close();
                }
                if (bitmapOutputStream != null) {
                    bitmapOutputStream.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        decodeOptions.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(bitmapCachePath);
        int actualWidth = decodeOptions.outWidth;
        int actualHeight = decodeOptions.outHeight;
        if (mMaxWidth == 0 && mMaxHeight == 0) {
            int sampleSize = 1;
// Path: restvolley/src/main/java/com/hujiang/restvolley/MD5Utils.java
// public class MD5Utils {
// 
//     private static final int HEX_FF = 0xFF;
// 
//     /**
//      *
//      * @param key for disk.
//      * @return hash key.
//      */
//     public static String hashKeyForDisk(String key) {
//         String cacheKey;
//         try {
//             final MessageDigest mDigest = MessageDigest.getInstance("MD5");
//             mDigest.update(key.getBytes());
//             cacheKey = bytesToHexString(mDigest.digest());
//         } catch (NoSuchAlgorithmException e) {
//             cacheKey = String.valueOf(key.hashCode());
//         }
//         return cacheKey;
//     }
// 
//     private static String bytesToHexString(byte[] bytes) {
//         StringBuilder sb = new StringBuilder();
//         for (int i = 0; i < bytes.length; i++) {
//             String hex = Integer.toHexString(HEX_FF & bytes[i]);
//             if (hex.length() == 1) {
//                 sb.append('0');
//             }
//             sb.append(hex);
//         }
//         return sb.toString();
//     }
// 
// }
// 
// Path: restvolley/src/main/java/com/hujiang/restvolley/compat/StreamBasedNetworkResponse.java
// public class StreamBasedNetworkResponse extends NetworkResponse {
// 
//     /** Raw data inputStream from this response. */
//     public final InputStream inputStream;
//     public final long contentLength;
// 
//     public StreamBasedNetworkResponse(int statusCode, InputStream inputStream, long contentLength, Map<String, String> headers, boolean notModified, long networkTimeMs) {
//         super(statusCode, null, headers, notModified, networkTimeMs);
//         this.inputStream = inputStream;
//         this.contentLength = contentLength;
//     }
// 
//     public StreamBasedNetworkResponse(int statusCode, InputStream inputStream, long contentLength, Map<String, String> headers, boolean notModified) {
//         super(statusCode, null, headers, notModified);
//         this.inputStream = inputStream;
//         this.contentLength = contentLength;
//     }
// 
//     public StreamBasedNetworkResponse(InputStream inputStream, long contentLength) {
//         super(null);
//         this.inputStream = inputStream;
//         this.contentLength = contentLength;
//     }
// 
//     public StreamBasedNetworkResponse(InputStream inputStream, long contentLength, Map<String, String> headers) {
//         super(null, headers);
//         this.inputStream = inputStream;
//         this.contentLength = contentLength;
//     }
// 
//     public StreamBasedNetworkResponse(int statusCode, byte[] data, Map<String, String> headers, boolean notModified, long networkTimeMs) {
//         super(statusCode, data, headers, notModified, networkTimeMs);
//         this.inputStream = null;
//         this.contentLength = data != null ? data.length : 0;
//     }
// 
//     public StreamBasedNetworkResponse(int statusCode, byte[] data, Map<String, String> headers, boolean notModified) {
//         super(statusCode, data, headers, notModified);
//         this.inputStream = null;
//         this.contentLength = data != null ? data.length : 0;
//     }
// 
//     public StreamBasedNetworkResponse(byte[] data) {
//         super(data);
//         this.inputStream = null;
//         this.contentLength = data != null ? data.length : 0;
//     }
// 
//     public StreamBasedNetworkResponse(byte[] data, Map<String, String> headers) {
//         super(data, headers);
//         this.inputStream = null;
//         this.contentLength = data != null ? data.length : 0;
//     }
// }
// 
// Path: restvolley/src/main/java/com/hujiang/restvolley/image/ImageProcessor.java
// public static final int BYTE_IN_PIX = 4;


// Path: restvolley/src/main/java/com/hujiang/restvolley/image/RVImageRequest.java
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.widget.ImageView;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyLog;
import com.hujiang.restvolley.MD5Utils;
import com.hujiang.restvolley.compat.StreamBasedNetworkResponse;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import static com.hujiang.restvolley.image.ImageProcessor.BYTE_IN_PIX;


        BufferedOutputStream bitmapOutputStream = null;
        try {
            bitmapOutputStream = new BufferedOutputStream(new FileOutputStream(bitmapCache));
            byte[] buffer = new byte[BUFFER_SIZE];
            int len;
            while ((len = bitmapStream.read(buffer)) != -1) {
                bitmapOutputStream.write(buffer, 0, len);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (bitmapStream != null) {
                    bitmapStream.close();
                }
                if (bitmapOutputStream != null) {
                    bitmapOutputStream.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        decodeOptions.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(bitmapCachePath);
        int actualWidth = decodeOptions.outWidth;
        int actualHeight = decodeOptions.outHeight;
        if (mMaxWidth == 0 && mMaxHeight == 0) {
            int sampleSize = 1;
            long desired_size = actualWidth * actualHeight * BYTE_IN_PIX;