| | |
| | | import android.widget.TextView; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.bumptech.glide.Glide; |
| | | import com.tejia.lijin.app.R; |
| | | import com.tejia.lijin.app.entity.goods.GoodsDetailInfo; |
| | | import com.tejia.lijin.app.entity.goods.GoodsDetailVO; |
| | | import com.tejia.lijin.app.util.GlideRoundTransform; |
| | | import com.wpc.library.util.common.DimenUtils; |
| | | import com.wpc.library.util.common.StringUtils; |
| | | |
| | |
| | | |
| | | public class GoodsDetailHongBaoListAdapter extends RecyclerView.Adapter { |
| | | private Context mContext; |
| | | private List<GoodsDetailInfo.HongBaoInfo> mList; |
| | | private List<GoodsDetailVO.GoodsHongBaoListVO> mList; |
| | | private boolean simpleMode; |
| | | |
| | | public GoodsDetailHongBaoListAdapter(Context context, List<GoodsDetailInfo.HongBaoInfo> list, boolean simpleMode) { |
| | | public GoodsDetailHongBaoListAdapter(Context context, List<GoodsDetailVO.GoodsHongBaoListVO> list, boolean simpleMode) { |
| | | this.mContext = context; |
| | | this.mList = list; |
| | | this.simpleMode = simpleMode; |
| | |
| | | @NonNull |
| | | @Override |
| | | public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
| | | return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_goods_detail_hongbao, null)); |
| | | return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_goods_detail_hongbao, parent, false)); |
| | | } |
| | | |
| | | @Override |
| | | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
| | | GoodsDetailInfo.HongBaoInfo hongBaoInfo = mList.get(position); |
| | | GoodsDetailVO.GoodsHongBaoListVO hongBaoInfo = mList.get(position); |
| | | final ViewHolder viewHolder = (ViewHolder) holder; |
| | | viewHolder.tv_more.setOnClickListener(new View.OnClickListener() { |
| | | viewHolder.fl_more.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (viewHolder.ll_hongbao_detail.getVisibility() == View.VISIBLE) |
| | | viewHolder.ll_hongbao_detail.setVisibility(View.GONE); |
| | | else { |
| | | viewHolder.ll_hongbao_detail.setVisibility(View.VISIBLE); |
| | | viewHolder.tv_more.setVisibility(View.GONE); |
| | | viewHolder.fl_more.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | boolean fanli = false; |
| | | boolean fanli = hongBaoInfo.getType() == 4; |
| | | |
| | | //初始化View显示 |
| | | setShowMode(viewHolder, fanli, simpleMode); |
| | | //设置红包详情 |
| | | setHongBaoDetailInfo(viewHolder, hongBaoInfo); |
| | | |
| | | //设置会员信息 |
| | | if (hongBaoInfo.getUserLevel() == null) { |
| | | viewHolder.ll_level_info.setVisibility(View.GONE); |
| | | } else { |
| | | viewHolder.ll_level_info.setVisibility(View.VISIBLE); |
| | | viewHolder.iv_level.setImageResource(R.drawable.icon_rank_2); |
| | | viewHolder.tv_level_desc.setText(hongBaoInfo.getUserLevel().getDesc()); |
| | | } |
| | | |
| | | |
| | | //设置资金 |
| | | SpannableString hbMoney = new SpannableString(hongBaoInfo.getHongBaoMoney()); |
| | | hbMoney.setSpan(new RelativeSizeSpan(1.5f), 1, (hongBaoInfo.getFinalMoney().indexOf(".") > -1 ? hongBaoInfo.getFinalMoney().indexOf(".") : hongBaoInfo.getFinalMoney().length()), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | SpannableString hbMoney = new SpannableString(hongBaoInfo.getSubMoney()); |
| | | hbMoney.setSpan(new RelativeSizeSpan(1.5f), 1, (hongBaoInfo.getSubMoney().indexOf(".") > -1 ? hongBaoInfo.getSubMoney().indexOf(".") : hongBaoInfo.getSubMoney().length()), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | viewHolder.tv_sub_money.setText(hbMoney); |
| | | viewHolder.tv_sub_money.setCompoundDrawablePadding(DimenUtils.dip2px(mContext, 8)); |
| | | if (fanli) { |
| | |
| | | |
| | | SpannableString finalMoney = new SpannableString(hongBaoInfo.getFinalMoney()); |
| | | finalMoney.setSpan(new RelativeSizeSpan(1.77f), 1, (hongBaoInfo.getFinalMoney().indexOf(".") > -1 ? hongBaoInfo.getFinalMoney().indexOf(".") : hongBaoInfo.getFinalMoney().length()), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | viewHolder.tv_actual_money.setText(finalMoney); |
| | | viewHolder.tv_final_money.setText(finalMoney); |
| | | |
| | | //简介 |
| | | if (StringUtils.isNullOrEmpty(hongBaoInfo.getDesc())) { |
| | |
| | | viewHolder.fl_main.setBackgroundResource(R.drawable.shape_goods_detail_hongbao_bg); |
| | | viewHolder.ll_hongbao_detail.setBackgroundResource(R.drawable.ic_goods_detail_hongbao_detail_fanli); |
| | | moreBg.setColor(Color.parseColor("#35A30E")); |
| | | viewHolder.tv_more.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.icon_goods_detail_hongbao_fanli_more, 0, 0); |
| | | viewHolder.iv_more.setImageResource(R.drawable.icon_goods_detail_hongbao_fanli_more); |
| | | } else { |
| | | viewHolder.fl_main.setBackgroundResource(R.drawable.shape_goods_detail_hongbao_high_level_bg); |
| | | viewHolder.ll_hongbao_detail.setBackgroundResource(R.drawable.ic_goods_detail_hongbao_detail_hb); |
| | | moreBg.setColor(Color.parseColor("#EC1F3F")); |
| | | viewHolder.tv_more.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.icon_goods_detail_hongbao_hb_more, 0, 0); |
| | | viewHolder.iv_more.setImageResource(R.drawable.icon_goods_detail_hongbao_hb_more); |
| | | } |
| | | |
| | | viewHolder.tv_more.setBackground(moreBg); |
| | | viewHolder.fl_more.setBackground(moreBg); |
| | | |
| | | if (simple) { |
| | | viewHolder.ll_level_info.setVisibility(View.GONE); |
| | | viewHolder.tv_more.setVisibility(View.GONE); |
| | | viewHolder.fl_more.setVisibility(View.GONE); |
| | | viewHolder.tv_desc.setVisibility(View.GONE); |
| | | } else { |
| | | viewHolder.ll_level_info.setVisibility(View.VISIBLE); |
| | | viewHolder.tv_more.setVisibility(View.VISIBLE); |
| | | viewHolder.fl_more.setVisibility(View.VISIBLE); |
| | | viewHolder.tv_desc.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | private void setHongBaoDetailInfo(ViewHolder viewHolder, GoodsDetailInfo.HongBaoInfo hongBaoInfo) { |
| | | private void setHongBaoDetailInfo(ViewHolder viewHolder, GoodsDetailVO.GoodsHongBaoListVO hongBaoInfo) { |
| | | |
| | | //隐藏超出的资金项目 |
| | | for (int i = hongBaoInfo.getPriceInfoList().size(); i < 4; i++) { |
| | | for (int i = hongBaoInfo.getPriceDetails().size(); i < 4; i++) { |
| | | |
| | | int viewId = mContext.getResources().getIdentifier( |
| | | "ll_money_" + i, |
| | |
| | | viewHolder.fl_main.findViewById(viewId).setVisibility(View.GONE); |
| | | } |
| | | |
| | | for (int i = hongBaoInfo.getPriceInfoList().size() - 1; i < 3; i++) { |
| | | for (int i = hongBaoInfo.getPriceDetails().size() - 1; i < 3; i++) { |
| | | int viewId = mContext.getResources().getIdentifier( |
| | | "v_hongbao_cut_" + i, |
| | | "id", |
| | |
| | | viewHolder.fl_main.findViewById(viewId).setVisibility(View.GONE); |
| | | } |
| | | |
| | | for (int i = 0; i < hongBaoInfo.getPriceInfoList().size(); i++) { |
| | | viewHolder.tv_money_names[i].setText(hongBaoInfo.getPriceInfoList().get(i).getPriceName()); |
| | | viewHolder.tv_moneys[i].setText(hongBaoInfo.getPriceInfoList().get(i).getMoney()); |
| | | for (int i = 0; i < hongBaoInfo.getPriceDetails().size(); i++) { |
| | | viewHolder.tv_money_names[i].setText(hongBaoInfo.getPriceDetails().get(i).getName()); |
| | | viewHolder.tv_moneys[i].setText(hongBaoInfo.getPriceDetails().get(i).getMoney()); |
| | | } |
| | | |
| | | viewHolder.tv_actual_money.setText(hongBaoInfo.getFinalMoney()); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public int getItemCount() { |
| | | return 0; |
| | | return mList == null ? 0 : mList.size(); |
| | | } |
| | | |
| | | class ViewHolder extends RecyclerView.ViewHolder { |
| | |
| | | TextView tv_sub_money; |
| | | TextView tv_sub_money_desc; |
| | | TextView tv_final_money; |
| | | TextView tv_more; |
| | | ImageView iv_more; |
| | | FrameLayout fl_more; |
| | | TextView tv_desc; |
| | | |
| | | |
| | |
| | | tv_sub_money = itemView.findViewById(R.id.tv_sub_money); |
| | | tv_sub_money_desc = itemView.findViewById(R.id.tv_sub_money_desc); |
| | | tv_final_money = itemView.findViewById(R.id.tv_final_money); |
| | | tv_more = itemView.findViewById(R.id.tv_more); |
| | | iv_more = itemView.findViewById(R.id.iv_more); |
| | | fl_more = itemView.findViewById(R.id.fl_more); |
| | | |
| | | tv_desc = itemView.findViewById(R.id.tv_desc); |
| | | ll_hongbao_detail = itemView.findViewById(R.id.ll_hongbao_detail); |
| | | ll_money_0 = itemView.findViewById(R.id.ll_money_0); |