@ProviderTag(messageContent = GoodsMsg.class, showReadState = true)
public class GoodsMsgProvider extends IContainerItemProvider.MessageProvider<GoodsMsg> {
private Context mContext;
public GoodsMsgProvider(Context context) {
mContext = context;
}
@Override
public void bindView(View view, int i, GoodsMsg goodsMsg, UIMessage uiMessage) {
//根据需求,适配数据
ViewHolder holder = (ViewHolder) view.getTag();
holder.tvGoodsName.setText(goodsMsg.getGoodsName());
holder.tvShopName.setText(goodsMsg.getShopName());
holder.tvGoodsPrice.setText(goodsMsg.getGoodsPriceMin());
GlideRoundTransform glideRoundTransform = new GlideRoundTransform(mContext, 8, GlideRoundTransform.CornerType.TOP);
Glide.with(mContext)
.load(goodsMsg.getGoodsCoverUrl())
.apply(new RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.transform(glideRoundTransform))
.placeholder(R.mipmap.icon_default_placeholder)
.into(holder.ivGoodsCover);
ImageLoaderUtil.loadImgCenterCrop(holder.ivShopLogo, goodsMsg.getShopLogo(), R.mipmap.icon_default_avatar_shop);
List<String> goodsTag = goodsMsg.getGoodsTag();
if (goodsTag != null && !goodsTag.isEmpty()) {
holder.tflGoodsTag.setVisibility(View.VISIBLE);
holder.tflGoodsTag.setAdapter(new TagAdapter<String>(goodsTag) {
@Override
public View getView(FlowLayout parent, int position, String s) {
TextView tv = (TextView) LayoutInflater.from(mContext).inflate(R.layout.item_goods_tag_bg, parent, false);
tv.setText(s);
return tv;
}
});
} else {
holder.tflGoodsTag.setVisibility(View.GONE);
}
}
@Override
public Spannable getContentSummary(GoodsMsg goodsMsg) {
return null;
}
@Override
public Spannable getContentSummary(Context context, GoodsMsg data) {
return new SpannableString("[商品信息]");
}
@Override
public void onItemClick(View view, int i, GoodsMsg goodsMsg, UIMessage uiMessage) {
String goodsId = goodsMsg.getGoodsId();
ARouter.getInstance()
.build(CommonARouterPath.GOODS_DETAIL_ACTIVITY)
.withString("id", goodsId)
.navigation();
}
@Override
public View newView(Context context, ViewGroup viewGroup) {
View view = LayoutInflater.from(context).inflate(R.layout.item_goods_msg, null);
view.setLayoutParams(new ViewGroup.LayoutParams((int) (ScreenUtil.getScreenWidth(context) * 2 / 3), ViewGroup.LayoutParams.WRAP_CONTENT));
ViewHolder holder = new ViewHolder();
holder.ivGoodsCover = view.findViewById(R.id.iv_goods_cover);
holder.ivShopLogo = view.findViewById(R.id.iv_shop_logo);
holder.tvGoodsPrice = view.findViewById(R.id.tv_goods_price);
holder.tvGoodsName = view.findViewById(R.id.tv_goods_name);
holder.tvShopName = view.findViewById(R.id.tv_shop_name);
holder.tflGoodsTag = view.findViewById(R.id.tfl_goods_tag);
view.setTag(holder);
return view;
}
private static class ViewHolder {
ImageView ivGoodsCover;
CircleImageView ivShopLogo;
TextView tvGoodsPrice, tvGoodsName, tvShopName;
TagFlowLayout tflGoodsTag;
}
}
GoodsMsgProvider
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...