| | |
| | | import com.app.hubert.guide.util.ScreenUtils; |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.tejia.lijin.app.util.goods.GoodsDetailListUtil; |
| | | import com.tejia.lijin.app.util.ui.GoodsDetailUtil; |
| | | import com.tejia.lijin.app.util.ui.GoodsRightViewHolder; |
| | | import com.wpc.library.util.SystemCommon; |
| | | import com.wpc.library.util.common.DimenUtils; |
| | | import com.tejia.lijin.app.R; |
| | |
| | | import com.tejia.lijin.app.util.ImageUtil; |
| | | import com.tejia.lijin.app.util.JumpActivityUtil; |
| | | import com.tejia.lijin.app.util.clipboard.ClipboardUtil; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | | /** |
| | | * 猜你喜欢dialog |
| | |
| | | dialog.addContentView(layout, new FrameLayout.LayoutParams( |
| | | FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT)); |
| | | |
| | | LinearLayout ll_item1 = layout.findViewById(R.id.ll_horizontal_item);//商品详情布局 |
| | | LinearLayout ll_goods_detail = layout.findViewById(R.id.ll_goods_detail);//商品详情布局 |
| | | RelativeLayout ll_not_item = layout.findViewById(R.id.ll_not_item);//未加入淘宝联盟布局 |
| | | TextView tv_go = layout.findViewById(R.id.tv_go); |
| | | TextView tv_left = layout.findViewById(R.id.tv_left); |
| | | |
| | | GradientDrawable gradientDrawable = new GradientDrawable(); |
| | | gradientDrawable.setCornerRadius(DimenUtils.dip2px(context, 40)); |
| | | gradientDrawable.setStroke(DimenUtils.dip2px(context, 1), context.getResources().getColor(R.color.theme)); |
| | | gradientDrawable.setColor(context.getResources().getColor(R.color.white)); |
| | | tv_left.setBackgroundDrawable(gradientDrawable); |
| | | tv_left.setVisibility(View.GONE); |
| | | |
| | | if (type == 4) {/**兼容未加入淘宝联盟的情况*/ |
| | | ll_item1.setVisibility(View.GONE);//商品详情 |
| | | ll_goods_detail.setVisibility(View.GONE);//商品详情 |
| | | ll_not_item.setVisibility(View.VISIBLE);//未加入淘宝联盟 |
| | | tv_go.setText("查看相似"); |
| | | tv_left.setText("查看相似"); |
| | | ImageView ll_not_img = layout.findViewById(R.id.ll_not_img); |
| | | TextView ll_not_title1 = layout.findViewById(R.id.ll_not_title1); |
| | | // 图片 |
| | |
| | | .into(ll_not_img); |
| | | ll_not_title1.setText(info.getGoods().getTitle());//纯标题 |
| | | if (positiveButtonClickListener != null) { |
| | | tv_go.setOnClickListener(new View.OnClickListener() { |
| | | tv_left.setOnClickListener(new View.OnClickListener() { |
| | | public void onClick(View v) { |
| | | positiveButtonClickListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE); |
| | | ClipboardUtil.emptyClipboard(context); |
| | |
| | | }); |
| | | } |
| | | } else {/**商品详情布局*/ |
| | | ll_item1.setVisibility(View.VISIBLE);//商品详情 |
| | | ll_goods_detail.setVisibility(View.VISIBLE);//商品详情 |
| | | ll_not_item.setVisibility(View.GONE);//未加入淘宝联盟 |
| | | |
| | | if (info.getLeft() != null) { |
| | | tv_left.setVisibility(View.VISIBLE); |
| | | tv_left.setText(info.getLeft().getName()); |
| | | if (positiveButtonClickListener != null) { |
| | | tv_left.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | JumpActivityUtil.jumpPage(context, info.getLeft().getJumpDetail(), info.getLeft().getParams()); |
| | | ClipboardUtil.emptyClipboard(context); |
| | | if (dialog.isShowing()) |
| | | dialog.dismiss(); |
| | | } |
| | | }); |
| | | } else |
| | | tv_left.setVisibility(View.GONE); |
| | | if (info.getRight() != null) { |
| | | tv_go.setText(info.getRight().getName()); |
| | | tv_go.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | JumpActivityUtil.jumpPage(context, info.getRight().getJumpDetail(), info.getRight().getParams()); |
| | | positiveButtonClickListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE); |
| | | ClipboardUtil.emptyClipboard(context); |
| | | } |
| | | }); |
| | | } else { |
| | | tv_go.setText("去看看"); |
| | | if (positiveButtonClickListener != null) { |
| | | tv_go.setOnClickListener(new View.OnClickListener() { |
| | | public void onClick(View v) { |
| | | positiveButtonClickListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE); |
| | | ClipboardUtil.emptyClipboard(context); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | LinearLayout ll_coupon_bg1 = layout.findViewById(R.id.ll_coupon_bg1); |
| | | ImageView iv_pic1 = layout.findViewById(R.id.iv_movie_cover1); |
| | | TextView tv_normal_price1 = layout.findViewById(R.id.tv_normal_price1); |
| | | TextView tv_shop_name1 = layout.findViewById(R.id.tv_shop_name1); |
| | | TextView tv_name1 = layout.findViewById(R.id.tv_movie_title1); |
| | | TextView tv_price1 = layout.findViewById(R.id.tv_price1); |
| | | TextView tv_coupon_price1 = layout.findViewById(R.id.tv_coupon_price1); |
| | | TextView tv_favourable1 = layout.findViewById(R.id.tv_favourable1); |
| | | TextView tv_rate_info = layout.findViewById(R.id.tv_rate_info); |
| | | |
| | | LinearLayout ll_discount_new = layout.findViewById(R.id.ll_discount_new); |
| | | TextView tv_discount_new = layout.findViewById(R.id.tv_discount_new); |
| | | |
| | | TextView tv_sale_num1 = layout.findViewById(R.id.tv_sale_num1); |
| | | TextView tv_sale_num2 = layout.findViewById(R.id.tv_sale_num2); |
| | | |
| | | LinearLayout ll_shop1 = layout.findViewById(R.id.ll_shop1); |
| | | |
| | | //不加商品类型图标(淘宝联盟不允许用链接搜索) |
| | | ImageUtil.showImageFaceDialog(context, info.getGoods().getTitle(), info.getGoods().getShopType(), tv_name1); |
| | | // tv_name1.setText(taoBaoGoodsBrief.getTitle());//纯标题 |
| | | tv_normal_price1.setText("¥" + info.getGoods().getZkPrice()); |
| | | tv_normal_price1.setPaintFlags(tv_normal_price1.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); |
| | | |
| | | // 图片 |
| | | Glide.with(context).load(info.getGoods().getPicUrl()). |
| | | placeholder(R.drawable.ic_goods_default).error(R.drawable.ic_goods_default). |
| | | transform(new GlideRoundTransform(context, 5)) |
| | | .diskCacheStrategy(DiskCacheStrategy.ALL) |
| | | .into(iv_pic1); |
| | | // ImageLoader.getInstance().displayImage(taoBaoGoodsBrief.getPicUrl(), iv_pic1, options); |
| | | if (info.getGoods().getShopInfo() != null && info.getGoods().getShopInfo().getShopName() != null) { |
| | | ll_shop1.setVisibility(View.VISIBLE); |
| | | tv_shop_name1.setText(info.getGoods().getShopInfo().getShopName()); |
| | | Drawable drawable = context.getResources().getDrawable(R.drawable.ic_shopci); |
| | | drawable.setBounds(0, 0, 27 * tv_shop_name1.getLineHeight() / 24, tv_shop_name1.getLineHeight());//第一0是距左边距离,第二0是距上边距离,30、35分别是长宽 |
| | | tv_shop_name1.setCompoundDrawables(drawable, null, null, null);//只放左边 |
| | | } else { |
| | | ll_shop1.setVisibility(View.GONE); |
| | | // v_top.setVisibility(position == 0 ? View.VISIBLE : View.GONE); |
| | | ImageView iv_pic = layout.findViewById(R.id.iv_pic); |
| | | try { |
| | | Glide.with(context).load(info.getGoods().getPicUrl()).apply(new RequestOptions().centerCrop()).transform(new GlideRoundTransform(context, 5)).transition(withCrossFade()).placeholder(R.drawable.ic_goods_default).diskCacheStrategy(DiskCacheStrategy.ALL).into(iv_pic); |
| | | } catch (IllegalArgumentException e) { |
| | | } |
| | | tv_price1.setTextColor(context.getResources().getColor(R.color.theme)); |
| | | |
| | | if (info.getGoods().getMoneyInfo() != null && info.getGoods().getMoneyInfo().getRateInfo() != null) |
| | | tv_rate_info.setText(info.getGoods().getMoneyInfo().getRateInfo()); |
| | | |
| | | if (info.getGoods().getMoneyInfo().getMoneyType() == 1) { |
| | | tv_favourable1.setBackgroundResource(R.drawable.shape_goods_list_price_fan); |
| | | tv_favourable1.setText("返 " + info.getGoods().getMoneyInfo().getFanliMoney()); |
| | | } else { |
| | | tv_favourable1.setBackgroundResource(R.drawable.shape_goods_list_price_fan); |
| | | tv_favourable1.setText("奖 " + info.getGoods().getMoneyInfo().getFanliMoney()); |
| | | } |
| | | |
| | | |
| | | String disCount; |
| | | |
| | | if (!info.getGoods().isHasCoupon()) { |
| | | ll_coupon_bg1.setVisibility(View.GONE); |
| | | disCount = "¥ " + info.getGoods().getZkPrice(); |
| | | if (info.getGoods().getGoodsType() == Constant.GOODS_TYPE_VIP) { |
| | | disCount = "¥ " + info.getGoods().getCouponPrice(); |
| | | } |
| | | } else { |
| | | ll_coupon_bg1.setVisibility(View.VISIBLE); |
| | | disCount = "¥ " + info.getGoods().getCouponPrice(); |
| | | tv_coupon_price1.setVisibility(View.VISIBLE); |
| | | tv_coupon_price1.setText("¥ " + info.getGoods().getCouponInfo().getAmount()); |
| | | } |
| | | |
| | | |
| | | tv_sale_num1.setTextColor((info.getGoods().getSalesType() == 1 || info.getGoods().getSalesType() == 4) ? |
| | | context.getResources().getColor(R.color.gray5) : info.getGoods().getSalesType() == 2 ? |
| | | context.getResources().getColor(R.color.goods_sale_num_text_color_orange) : |
| | | context.getResources().getColor(R.color.goods_sale_num_text_color_blue)); |
| | | tv_sale_num1.setText(info.getGoods().getSalesType() == 1 ? "月销 " + info.getGoods().getSalesCount() : |
| | | info.getGoods().getSalesType() == 2 ? "2小时销量 " + info.getGoods().getSalesCount() : info.getGoods().getSalesType() == 3 ? |
| | | "今日销量 " + info.getGoods().getSalesCount() : "总销量 " + info.getGoods().getSalesCount()); |
| | | tv_sale_num2.setTextColor((info.getGoods().getSalesType() == 1 || info.getGoods().getSalesType() == 4) ? |
| | | context.getResources().getColor(R.color.gray5) : info.getGoods().getSalesType() == 2 ? |
| | | context.getResources().getColor(R.color.goods_sale_num_text_color_orange) : |
| | | context.getResources().getColor(R.color.goods_sale_num_text_color_blue)); |
| | | tv_sale_num2.setText(info.getGoods().getSalesType() == 1 ? "月销 " + info.getGoods().getSalesCount() : |
| | | info.getGoods().getSalesType() == 2 ? "2小时销量 " + info.getGoods().getSalesCount() : info.getGoods().getSalesType() == 3 ? |
| | | "今日销量 " + info.getGoods().getSalesCount() : "总销量 " + info.getGoods().getSalesCount()); |
| | | |
| | | tv_sale_num2.setVisibility(View.GONE); |
| | | if (info.getGoods().getGoodsType() == Constant.GOODS_TYPE_VIP) { |
| | | tv_sale_num1.setVisibility(View.GONE); |
| | | ll_discount_new.setVisibility(View.VISIBLE); |
| | | tv_discount_new.setText(info.getGoods().getDiscount()); |
| | | } else { |
| | | ll_discount_new.setVisibility(View.GONE); |
| | | tv_sale_num1.setVisibility(View.VISIBLE); |
| | | |
| | | } |
| | | |
| | | int pos = disCount.indexOf("."); |
| | | Spannable span = new SpannableString(disCount); |
| | | span.setSpan(new RelativeSizeSpan(1.2f), 1, pos > 1 ? pos : disCount.length(), |
| | | Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | //span.setSpan(new StyleSpan(Typeface.BOLD), 1, disCount.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | tv_price1.setText(span); |
| | | |
| | | |
| | | //商品详情填充 |
| | | GoodsDetailListUtil.setGoodsDetail(context, info.getGoods(), new GoodsRightViewHolder(ll_goods_detail)); |
| | | } |
| | | |
| | | // set the confirm button |
| | | |
| | | final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); |
| | | //动态改变shape |
| | | GradientDrawable shape = new GradientDrawable(); |
| | | shape.setCornerRadius(ScreenUtils.dp2px(context, 100)); |
| | | //设置颜色 |
| | | shape.setColor(context.getResources().getColor(R.color.theme)); |
| | | //设置大小 |
| | | tv_go.setBackground(shape); |
| | | |
| | | |
| | | if (negativeButtonClickListener != null) { |
| | |
| | | dialog.setContentView(layout); |
| | | |
| | | android.view.WindowManager.LayoutParams params = dialog.getWindow().getAttributes(); |
| | | params.width = (int) ((SystemCommon.getScreenWidth(context) * 19) / 23); |
| | | params.width = (int) ((SystemCommon.getScreenWidth(context) * 4) / 5); |
| | | params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT; |
| | | dialog.getWindow().setAttributes(params); |
| | | dialog.setCanceledOnTouchOutside(false); |