|
|
@@ -11,8 +11,6 @@ import androidx.annotation.NonNull;
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
|
import com.bumptech.glide.Glide;
|
|
|
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
|
|
-import com.bumptech.glide.request.RequestOptions;
|
|
|
import com.bumptech.glide.request.target.SimpleTarget;
|
|
|
import com.bumptech.glide.request.transition.Transition;
|
|
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
@@ -25,17 +23,20 @@ import com.miekir.common.utils.ToastTool;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* @author Miekir
|
|
|
* @date 2020/7/6 20:08
|
|
|
* Description: 首页商品适配器
|
|
|
*/
|
|
|
public class TemplateAdapter extends BaseQuickAdapter<CouponBean, BaseViewHolder> {
|
|
|
- //private int mRadius = 8;
|
|
|
+ private int mRadius = 8;
|
|
|
+ private Context mContext;
|
|
|
|
|
|
public TemplateAdapter(Context context, @Nullable List<CouponBean> data) {
|
|
|
super(R.layout.item_template, data);
|
|
|
- //mRadius = (int) context.getResources().getDimension(R.dimen.margin_s);
|
|
|
+ mRadius = (int) context.getResources().getDimension(R.dimen.margin_s);
|
|
|
+ mContext = context;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -44,20 +45,27 @@ public class TemplateAdapter extends BaseQuickAdapter<CouponBean, BaseViewHolder
|
|
|
if (couponBean.isCoverUrlLocal) {
|
|
|
int resourceId = Integer.parseInt(couponBean.coverUrl);
|
|
|
iv_template.setImageResource(resourceId);
|
|
|
+ //Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), resourceId);
|
|
|
+ // 圆角
|
|
|
+ //RoundedBitmapDrawable roundDrawable = RoundedBitmapDrawableFactory.create(mContext.getResources(), bitmap);
|
|
|
+ //roundDrawable.setCornerRadius(48);
|
|
|
+ //iv_template.setImageDrawable(roundDrawable);
|
|
|
+ // 这些处理都是把drawable圆角了,如果drawable本身尺寸比较小,就起不到圆角效果
|
|
|
} else {
|
|
|
// 圆角
|
|
|
Glide.with(mContext).load(couponBean.coverUrl)
|
|
|
- //.apply(RequestOptions.bitmapTransform(new RoundedCorners(48)))
|
|
|
+ //.transform(new CenterCrop(), new RoundedCorners(48))
|
|
|
//.apply(RequestOptions.bitmapTransform(new RoundedCorners(mRadius)))
|
|
|
- .apply(new RequestOptions()
|
|
|
- .skipMemoryCache(true)
|
|
|
- .diskCacheStrategy(DiskCacheStrategy.NONE))
|
|
|
+ //.apply(new RequestOptions()
|
|
|
+ // .skipMemoryCache(true)
|
|
|
+ // .diskCacheStrategy(DiskCacheStrategy.NONE))
|
|
|
+ //.centerCrop() 千万不要加,加了就没有圆角效果了
|
|
|
//先加载原图大小的十分之一
|
|
|
.thumbnail(0.1f)
|
|
|
.into(new SimpleTarget<Drawable>() {
|
|
|
@Override
|
|
|
public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
|
|
|
- iv_template.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
|
|
+ //iv_template.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
|
|
iv_template.setImageDrawable(resource);
|
|
|
}
|
|
|
});
|