// Path: client/FourFun/app/src/main/java/com/joker/fourfun/widget/GlideCircleTransform.java
// public class GlideCircleTransform extends BitmapTransformation {
//     public GlideCircleTransform(Context context) {
//         super(context);
//     }
// 
//     public GlideCircleTransform(BitmapPool bitmapPool) {
//         super(bitmapPool);
//     }
// 
//     @Override
//     protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
//         return circleCrop(pool, toTransform);
//     }
// 
//     private Bitmap circleCrop(BitmapPool pool, Bitmap source) {
// 
//         int size = Math.min(source.getWidth(), source.getHeight());
// 
//         int width = (source.getWidth() - size) / 2;
//         int height = (source.getHeight() - size) / 2;
// 
//         Bitmap bitmap = pool.get(size, size, Bitmap.Config.ARGB_8888);
//         if (bitmap == null) {
//             bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
//         }
// 
//         Canvas canvas = new Canvas(bitmap);
//         Paint paint = new Paint();
//         BitmapShader shader =
//                 new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
//         if (width != 0 || height != 0) {
//             // source isn't square, move viewport to center
//             Matrix matrix = new Matrix();
//             matrix.setTranslate(-width, -height);
//             shader.setLocalMatrix(matrix);
//         }
//         paint.setShader(shader);
//         paint.setAntiAlias(true);
// 
//         float r = size / 2f;
//         canvas.drawCircle(r, r, r, paint);
// 
//         return bitmap;
//     }
// 
//     @Override
//     public String getId() {
//         return getClass().getName();
//     }
// }


import android.content.Context;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.joker.fourfun.widget.GlideCircleTransform;
package com.joker.fourfun.utils;



/**
 * Created by joker on 2016/12/6.
 */

public class GlideUtil {
    // 磁盘缓存图片所有大小，centerCrop 大小
    public static void setImage(Context context, String imageUrl, ImageView targetView) {
        Glide.with(context)
                .load(imageUrl)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
//                .thumbnail(0.5f)
                .centerCrop()
                .into(targetView);
    }

    //圆形 ImageView
    public static void setCirCleImage(Context context, String imageUrl, ImageView targetView) {
        Glide.with(context)
                .load(imageUrl)
// Path: client/FourFun/app/src/main/java/com/joker/fourfun/widget/GlideCircleTransform.java
// public class GlideCircleTransform extends BitmapTransformation {
//     public GlideCircleTransform(Context context) {
//         super(context);
//     }
// 
//     public GlideCircleTransform(BitmapPool bitmapPool) {
//         super(bitmapPool);
//     }
// 
//     @Override
//     protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
//         return circleCrop(pool, toTransform);
//     }
// 
//     private Bitmap circleCrop(BitmapPool pool, Bitmap source) {
// 
//         int size = Math.min(source.getWidth(), source.getHeight());
// 
//         int width = (source.getWidth() - size) / 2;
//         int height = (source.getHeight() - size) / 2;
// 
//         Bitmap bitmap = pool.get(size, size, Bitmap.Config.ARGB_8888);
//         if (bitmap == null) {
//             bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
//         }
// 
//         Canvas canvas = new Canvas(bitmap);
//         Paint paint = new Paint();
//         BitmapShader shader =
//                 new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
//         if (width != 0 || height != 0) {
//             // source isn't square, move viewport to center
//             Matrix matrix = new Matrix();
//             matrix.setTranslate(-width, -height);
//             shader.setLocalMatrix(matrix);
//         }
//         paint.setShader(shader);
//         paint.setAntiAlias(true);
// 
//         float r = size / 2f;
//         canvas.drawCircle(r, r, r, paint);
// 
//         return bitmap;
//     }
// 
//     @Override
//     public String getId() {
//         return getClass().getName();
//     }
// }


// Path: client/FourFun/app/src/main/java/com/joker/fourfun/utils/GlideUtil.java
import android.content.Context;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.joker.fourfun.widget.GlideCircleTransform;

package com.joker.fourfun.utils;



/**
 * Created by joker on 2016/12/6.
 */

public class GlideUtil {
    // 磁盘缓存图片所有大小，centerCrop 大小
    public static void setImage(Context context, String imageUrl, ImageView targetView) {
        Glide.with(context)
                .load(imageUrl)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
//                .thumbnail(0.5f)
                .centerCrop()
                .into(targetView);
    }

    //圆形 ImageView
    public static void setCirCleImage(Context context, String imageUrl, ImageView targetView) {
        Glide.with(context)
                .load(imageUrl)
                .transform(new GlideCircleTransform(context))