// Path: app/src/main/java/org/nicky/easyemoji/image/transform/GlideCircleTransform.java
// public class GlideCircleTransform extends BitmapTransformation {
//     public GlideCircleTransform(Context context) {
//         super(context);
//     }
// 
//     @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
//         return circleCrop(pool, toTransform);
//     }
// 
//     private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
//         if (source == null) return null;
// 
//         int size = Math.min(source.getWidth(), source.getHeight());
//         int x = (source.getWidth() - size) / 2;
//         int y = (source.getHeight() - size) / 2;
// 
//         // TODO this could be acquired from the pool too
//         Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
// 
//         Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
//         if (result == null) {
//             result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
//         }
// 
//         Canvas canvas = new Canvas(result);
//         Paint paint = new Paint();
//         paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
//         paint.setAntiAlias(true);
//         float r = size / 2f;
//         canvas.drawCircle(r, r, r, paint);
//         return result;
//     }
// 
//     @Override public String getId() {
//         return getClass().getName();
//     }
// }
// 
// Path: app/src/main/java/org/nicky/easyemoji/image/transform/GlideRoundTransform.java
// public class GlideRoundTransform extends BitmapTransformation {
// 
//     private static float radius = 0f;
// 
//     public GlideRoundTransform(Context context) {
//         this(context, 4);
//     }
// 
//     public GlideRoundTransform(Context context, int dp) {
//         super(context);
//         this.radius = Resources.getSystem().getDisplayMetrics().density * dp;
//     }
// 
//     @Override
//     protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
//         return roundCrop(pool, toTransform);
//     }
// 
//     private static Bitmap roundCrop(BitmapPool pool, Bitmap source) {
//         if (source == null) return null;
// 
//         Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
//         if (result == null) {
//             result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
//         }
// 
//         Canvas canvas = new Canvas(result);
//         Paint paint = new Paint();
//         paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
//         paint.setAntiAlias(true);
//         RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
//         canvas.drawRoundRect(rectF, radius, radius, paint);
//         return result;
//     }
// 
//     @Override public String getId() {
//         return getClass().getName() + Math.round(radius);
//     }
// }


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import com.bumptech.glide.GenericRequestBuilder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.Target;
import org.nicky.easyemoji.image.transform.GlideCircleTransform;
import org.nicky.easyemoji.image.transform.GlideRoundTransform;
            req.placeholder(defaultIcon);
        }
        req.into(new BitmapImageViewTarget(imageView) {
            @Override
            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                super.onResourceReady(resource, glideAnimation);
                if (listener != null) {
                    listener.onLoadCompleted(uri, imageView, resource);
                }
            }

            @Override
            public void onLoadFailed(Exception e, Drawable errorDrawable) {
                super.onLoadFailed(e, errorDrawable);
                if (listener != null) {
                    listener.onLoadFailed(uri, imageView);
                }
            }
        });
    }


    /**
     * 重载方法 加载展示圆形图片
     * @param round 调用方传布尔值即视为要加载圆形图片
     */
    public void displayImage(Context context, String uri, ImageView view , int defaultIcon, boolean round) {
        Glide.with(context)
                .load(uri)
                .diskCacheStrategy(mDiskCacheStrategy)
// Path: app/src/main/java/org/nicky/easyemoji/image/transform/GlideCircleTransform.java
// public class GlideCircleTransform extends BitmapTransformation {
//     public GlideCircleTransform(Context context) {
//         super(context);
//     }
// 
//     @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
//         return circleCrop(pool, toTransform);
//     }
// 
//     private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
//         if (source == null) return null;
// 
//         int size = Math.min(source.getWidth(), source.getHeight());
//         int x = (source.getWidth() - size) / 2;
//         int y = (source.getHeight() - size) / 2;
// 
//         // TODO this could be acquired from the pool too
//         Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
// 
//         Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
//         if (result == null) {
//             result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
//         }
// 
//         Canvas canvas = new Canvas(result);
//         Paint paint = new Paint();
//         paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
//         paint.setAntiAlias(true);
//         float r = size / 2f;
//         canvas.drawCircle(r, r, r, paint);
//         return result;
//     }
// 
//     @Override public String getId() {
//         return getClass().getName();
//     }
// }
// 
// Path: app/src/main/java/org/nicky/easyemoji/image/transform/GlideRoundTransform.java
// public class GlideRoundTransform extends BitmapTransformation {
// 
//     private static float radius = 0f;
// 
//     public GlideRoundTransform(Context context) {
//         this(context, 4);
//     }
// 
//     public GlideRoundTransform(Context context, int dp) {
//         super(context);
//         this.radius = Resources.getSystem().getDisplayMetrics().density * dp;
//     }
// 
//     @Override
//     protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
//         return roundCrop(pool, toTransform);
//     }
// 
//     private static Bitmap roundCrop(BitmapPool pool, Bitmap source) {
//         if (source == null) return null;
// 
//         Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
//         if (result == null) {
//             result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
//         }
// 
//         Canvas canvas = new Canvas(result);
//         Paint paint = new Paint();
//         paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
//         paint.setAntiAlias(true);
//         RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
//         canvas.drawRoundRect(rectF, radius, radius, paint);
//         return result;
//     }
// 
//     @Override public String getId() {
//         return getClass().getName() + Math.round(radius);
//     }
// }


// Path: app/src/main/java/org/nicky/easyemoji/image/ImageLoader.java
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import com.bumptech.glide.GenericRequestBuilder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.Target;
import org.nicky.easyemoji.image.transform.GlideCircleTransform;
import org.nicky.easyemoji.image.transform.GlideRoundTransform;

            req.placeholder(defaultIcon);
        }
        req.into(new BitmapImageViewTarget(imageView) {
            @Override
            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                super.onResourceReady(resource, glideAnimation);
                if (listener != null) {
                    listener.onLoadCompleted(uri, imageView, resource);
                }
            }

            @Override
            public void onLoadFailed(Exception e, Drawable errorDrawable) {
                super.onLoadFailed(e, errorDrawable);
                if (listener != null) {
                    listener.onLoadFailed(uri, imageView);
                }
            }
        });
    }


    /**
     * 重载方法 加载展示圆形图片
     * @param round 调用方传布尔值即视为要加载圆形图片
     */
    public void displayImage(Context context, String uri, ImageView view , int defaultIcon, boolean round) {
        Glide.with(context)
                .load(uri)
                .diskCacheStrategy(mDiskCacheStrategy)
                .transform(new GlideCircleTransform(context))