//package com.yidianling.ydlcommon.view.widgets;
//
//import android.content.Context;
//import android.content.res.Resources;
//import android.graphics.Bitmap;
//import android.graphics.BitmapShader;
//import android.graphics.Canvas;
//import android.graphics.Paint;
//import android.graphics.RectF;
//import android.support.annotation.NonNull;
//
//import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
//import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
//
//import java.security.MessageDigest;
//
///**
// * @author jiucheng
// * @描述:glide加载图片：只有顶部圆角
// * @Copyright Copyright (c) 2018
// * @Company 壹点灵
// * @date 2018/7/30
// */
//
//public class GlideRoundTopTransform extends BitmapTransformation {
//
//    private static float radius = 0f;
//
//    public GlideRoundTopTransform(Context contex) {
//        this(contex, 4);
//    }
//
//    public GlideRoundTopTransform(Context context, int dp) {
//        super(context);
//        this.radius = Resources.getSystem().getDisplayMetrics().density * dp;
//
//    }
//
//    @Override
//    protected Bitmap transform(@NonNull BitmapPool pool, @NonNull 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);
//        canvas.drawRect(new RectF(0, radius, source.getWidth(), source.getHeight()), paint);
//        return result;
//    }
//
//    @Override
//    public void updateDiskCacheKey(MessageDigest messageDigest) {
//
//    }
//
//    public String getId() {
//        return getClass().getName() + Math.round(radius);
//    }
//
//}
