| | |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer; |
| | | import com.tejia.lijin.app.ui.recommend.GoodsDetailActivity; |
| | | import com.tejia.lijin.app.util.goods.GoodsDetailListUtil; |
| | | import com.tejia.lijin.app.util.ui.GoodsRightViewHolder; |
| | | import com.viewpagerindicator.CirclePageIndicator; |
| | | import com.wpc.library.util.SystemCommon; |
| | | import com.wpc.library.util.common.DimenUtils; |
| | |
| | | |
| | | |
| | | if (circleContentHolder.rv_content.getItemDecorationCount() == 0) { |
| | | circleContentHolder.rv_content.addItemDecoration(new SpaceItemDecoration(largeImageCount, smallImageCount + invalidImageCount, goodsCount, commentCount, circleContent.getLineNum(), DimenUtils.dip2px(mContext, 2))); |
| | | circleContentHolder.rv_content.addItemDecoration(new SpaceItemDecoration(largeImageCount, smallImageCount + invalidImageCount, goodsCount, commentCount, circleContent.getLineNum(), DimenUtils.dip2px(mContext, 1))); |
| | | } else { |
| | | SpaceItemDecoration spaceItemDecoration = (SpaceItemDecoration) circleContentHolder.rv_content.getItemDecorationAt(0); |
| | | spaceItemDecoration.initData(largeImageCount, smallImageCount + invalidImageCount, goodsCount, commentCount, circleContent.getLineNum(), DimenUtils.dip2px(mContext, 2)); |
| | | spaceItemDecoration.initData(largeImageCount, smallImageCount + invalidImageCount, goodsCount, commentCount, circleContent.getLineNum(), DimenUtils.dip2px(mContext, 1)); |
| | | } |
| | | |
| | | if (maxImgHeight == null) { |
| | |
| | | if (imgInfo.isLarge()) |
| | | width = maxImgWidth; |
| | | else { |
| | | width = (maxImgWidth - DimenUtils.dip2px(mContext, 2) * 8) / 3; |
| | | width = (maxImgWidth - DimenUtils.dip2px(mContext, 2) * 3) / 3; |
| | | } |
| | | height = (int) (width * ratio); |
| | | params.width = width; |
| | |
| | | }); |
| | | |
| | | } else if (holder1 instanceof GoodsViewHolder) { |
| | | |
| | | |
| | | GoodsViewHolder goodsViewHolder = (GoodsViewHolder) holder1; |
| | | |
| | | final TaoBaoGoodsBrief info = goods; |
| | | String disCount; |
| | | if (info.isHasCoupon()) { |
| | | goodsViewHolder.ll_coupon_bg.setVisibility(View.VISIBLE); |
| | | disCount = "¥ " + info.getCouponPrice(); |
| | | goodsViewHolder.tv_coupon_price.setText("¥ " + info.getCouponInfo().getAmount()); |
| | | } else { |
| | | goodsViewHolder.ll_coupon_bg.setVisibility(View.GONE); |
| | | disCount = "¥ " + info.getZkPrice(); |
| | | } |
| | | |
| | | if (info.getShopType() == 11) {//天猫 |
| | | goodsViewHolder.iv_shop_type.setImageResource(R.drawable.ic_tmall); |
| | | } else if (info.getShopType() == 20 || info.getShopType() == 21) { |
| | | goodsViewHolder.iv_shop_type.setImageResource(R.drawable.ic_jingdong); |
| | | } else if (info.getShopType() == 30) { |
| | | goodsViewHolder.iv_shop_type.setImageResource(R.drawable.ic_pinduoduo); |
| | | } else { |
| | | goodsViewHolder.iv_shop_type.setImageResource(R.drawable.icon); |
| | | } |
| | | |
| | | int pos = disCount.indexOf("."); |
| | | Spannable span = new SpannableString(disCount); |
| | | span.setSpan(new RelativeSizeSpan(1.54f), 1, pos > 1 ? pos : disCount.length(), |
| | | Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | goodsViewHolder.tv_price.setText(span); |
| | | |
| | | goodsViewHolder.tv_sales_num.setText(info.getSalesType() == 1 ? "月销 " + info.getSalesCount() : |
| | | info.getSalesType() == 2 ? "2小时销量 " + info.getSalesCount() : info.getSalesType() == 3 ? |
| | | "今日销量 " + info.getSalesCount() : "总销量 " + info.getSalesCount()); |
| | | |
| | | |
| | | goodsViewHolder.tv_zkprice.setText("¥" + info.getZkPrice()); |
| | | goodsViewHolder.tv_zkprice.setPaintFlags(goodsViewHolder.tv_zkprice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); |
| | | |
| | | goodsViewHolder.tv_favourable.setBackgroundResource(R.drawable.shape_goods_list_price_fan); |
| | | goodsViewHolder.tv_favourable.setText(" 奖 " + info.getMoneyInfo().getShareMoney()); |
| | | goodsViewHolder.tv_favourable.setVisibility(View.GONE); |
| | | |
| | | if (info.getState() != 0) { |
| | | GoodsDetailListUtil.setGoodsDetail(context, content.getGoods(), goodsViewHolder.goodsRightViewHolder); |
| | | if (content.getGoods().getState() != 0) { |
| | | goodsViewHolder.view.setOnClickListener(null); |
| | | goodsViewHolder.iv_state_invalid.setVisibility(View.VISIBLE); |
| | | } else { |
| | |
| | | public void onClick(View v) { |
| | | //跳转商品详情 |
| | | Intent intent = new Intent(mContext, GoodsDetailActivity.class); |
| | | intent.putExtra("goodsId", info.getGoodsId()); |
| | | intent.putExtra("goodsType", info.getGoodsType()); |
| | | intent.putExtra("goodsId", content.getGoods().getGoodsId()); |
| | | intent.putExtra("goodsType", content.getGoods().getGoodsType()); |
| | | intent.putExtra("from", "faquan"); |
| | | mContext.startActivity(intent); |
| | | } |
| | |
| | | |
| | | class GoodsViewHolder extends RecyclerView.ViewHolder { |
| | | private View view; |
| | | //商品信息控件 |
| | | private TextView tv_price, tv_zkprice, tv_sales_num, tv_coupon_price, tv_favourable; |
| | | private LinearLayout ll_coupon_bg; |
| | | private GoodsRightViewHolder goodsRightViewHolder; |
| | | //过期标识 |
| | | private ImageView iv_state_invalid, iv_shop_type; |
| | | private ImageView iv_state_invalid; |
| | | |
| | | public GoodsViewHolder(View view) { |
| | | super(view); |
| | | this.view = view; |
| | | tv_price = view.findViewById(R.id.tv_price); |
| | | tv_zkprice = view.findViewById(R.id.tv_zkprice); |
| | | tv_sales_num = view.findViewById(R.id.tv_sales_num); |
| | | tv_coupon_price = view.findViewById(R.id.tv_coupon_price1); |
| | | tv_favourable = view.findViewById(R.id.tv_favourable); |
| | | ll_coupon_bg = view.findViewById(R.id.ll_coupon_bg1); |
| | | iv_state_invalid = view.findViewById(R.id.iv_state_invalid); |
| | | iv_shop_type = view.findViewById(R.id.iv_shop_type); |
| | | goodsRightViewHolder = new GoodsRightViewHolder(view); |
| | | } |
| | | } |
| | | } |
| | |
| | | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { |
| | | int position = parent.getChildLayoutPosition(view); |
| | | if (position < largeImgCount) { |
| | | outRect.bottom = space * 3; |
| | | outRect.bottom = space * 6; |
| | | if (position == 0) |
| | | outRect.top = 0; |
| | | } else if (position < largeImgCount + smallImageCount) { |
| | |
| | | outRect.left = space; |
| | | outRect.right = space; |
| | | } |
| | | //判断是否为最后一行 |
| | | int currentRow = cposition / lineNum; |
| | | int totalRow=smallImageCount%lineNum==0?smallImageCount/lineNum:smallImageCount/lineNum+1; |
| | | if(currentRow+1==totalRow){ |
| | | outRect.bottom = space * 6; |
| | | } |
| | | |
| | | |
| | | |
| | | } else if (position < largeImgCount + smallImageCount + goodsCount) { |
| | | outRect.bottom = space; |
| | | outRect.bottom = space * 3; |
| | | outRect.top = 0; |
| | | outRect.left = 0; |
| | | outRect.right = 0; |
| | | } else if (position < largeImgCount + smallImageCount + goodsCount + commentCount) { |
| | | outRect.bottom = space * 2; |
| | | outRect.top = space * 2; |
| | | outRect.bottom = space * 3; |
| | | outRect.top = space * 3; |
| | | int cposition = position - (largeImgCount + smallImageCount + goodsCount + commentCount); |
| | | if (cposition == 0 && goodsCount > 0) |
| | | outRect.top = 0; |