|
|
@@ -34,49 +34,43 @@ public class CouponAdapter extends BaseQuickAdapter<CouponBean, BaseViewHolder>
|
|
|
private Context mContext;
|
|
|
|
|
|
public CouponAdapter(Context context, @Nullable List<CouponBean> data) {
|
|
|
- super(R.layout.item_template, data);
|
|
|
+ super(R.layout.item_coupon, data);
|
|
|
mRadius = (int) context.getResources().getDimension(R.dimen.margin_s);
|
|
|
mContext = context;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void convert(@NonNull BaseViewHolder holder, CouponBean couponBean) {
|
|
|
- ImageView iv_template = holder.getView(R.id.iv_template);
|
|
|
+ ImageView iv_coupon = holder.getView(R.id.iv_coupon);
|
|
|
// 解决图片错乱
|
|
|
- iv_template.setTag(R.id.iv_template, couponBean.coverUrl);
|
|
|
- if (couponBean.isCoverUrlLocal) {
|
|
|
- int resourceId = Integer.parseInt(couponBean.coverUrl);
|
|
|
- iv_template.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
|
|
- iv_template.setImageResource(resourceId);
|
|
|
- } else {
|
|
|
- // 圆角
|
|
|
- Glide.with(mContext).load(couponBean.coverUrl)
|
|
|
- //先加载原图大小的十分之一
|
|
|
- .thumbnail(0.1f)
|
|
|
- .into(new SimpleTarget<Drawable>() {
|
|
|
- @Override
|
|
|
- public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
|
|
|
- if (resource == null) {
|
|
|
- iv_template.setImageResource(R.mipmap.logo_gray);
|
|
|
- return;
|
|
|
- }
|
|
|
+ iv_coupon.setTag(R.id.iv_coupon, couponBean.coverUrl);
|
|
|
|
|
|
- String coverUrl = null;
|
|
|
- try {
|
|
|
- coverUrl = (String) iv_template.getTag(R.id.iv_template);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- if (TextUtils.isEmpty(coverUrl) || !TextUtils.equals(coverUrl, couponBean.coverUrl)) {
|
|
|
- iv_template.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
|
|
- iv_template.setImageResource(R.mipmap.logo_gray);
|
|
|
- } else {
|
|
|
- iv_template.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
|
|
- iv_template.setImageDrawable(resource);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ Glide.with(mContext).load(couponBean.coverUrl)
|
|
|
+ //先加载原图大小的十分之一
|
|
|
+ .thumbnail(0.1f)
|
|
|
+ .into(new SimpleTarget<Drawable>() {
|
|
|
+ @Override
|
|
|
+ public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
|
|
|
+ if (resource == null) {
|
|
|
+ iv_coupon.setImageResource(R.mipmap.logo_gray);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String coverUrl = null;
|
|
|
+ try {
|
|
|
+ coverUrl = (String) iv_coupon.getTag(R.id.iv_coupon);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (TextUtils.isEmpty(coverUrl) || !TextUtils.equals(coverUrl, couponBean.coverUrl)) {
|
|
|
+ iv_coupon.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
|
|
+ iv_coupon.setImageResource(R.mipmap.logo_gray);
|
|
|
+ } else {
|
|
|
+ iv_coupon.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
|
|
+ iv_coupon.setImageDrawable(resource);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
|
|
|
holder.setText(R.id.tv_template, couponBean.couponName);
|
|
|
@@ -87,7 +81,6 @@ public class CouponAdapter extends BaseQuickAdapter<CouponBean, BaseViewHolder>
|
|
|
ToastTool.showShort("敬请期待");
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
ActivityTool.openUrl((Activity) mContext, couponBean.jumpUrl);
|
|
|
}
|
|
|
});
|