admin
2021-06-11 ae4dc86b64bd8ef85bc832106741fb98e8d516da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package com.tejia.lijin.app.util.goods;
 
import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan;
import android.view.View;
 
import com.tejia.lijin.app.R;
import com.tejia.lijin.app.entity.TaoBaoGoodsBrief;
import com.tejia.lijin.app.util.Constant;
import com.tejia.lijin.app.util.ImageUtil;
import com.tejia.lijin.app.util.SetLabels;
import com.tejia.lijin.app.util.downutil.StringUtils;
import com.tejia.lijin.app.util.ui.GoodsRightViewHolder;
 
public class GoodsDetailListUtil {
 
    public static void setGoodsDetail(Context mContext, TaoBaoGoodsBrief info, GoodsRightViewHolder viewHolder) {
 
        if (viewHolder.ll_labels != null) {
            viewHolder.ll_labels.setVisibility(View.GONE);
//            列表不展示标签
//            if (viewHolder.ll_labels.getChildCount() > 0) {
//                viewHolder.ll_labels.removeAllViews();
//            }
//            if (info.getLabels() != null &&
//                    info.getLabels().size() > 0) {
//                viewHolder.ll_labels.setVisibility(View.VISIBLE);
//                SetLabels.addLabel(mContext, viewHolder.ll_labels,
//                        info.getLabels());
//            } else {
//                viewHolder.ll_labels.setVisibility(View.GONE);
//            }
        }
 
        ImageUtil.showImageFace(mContext, info.getTitle(), info.getShopType(), viewHolder.tv_name);
        viewHolder.tv_price.setText("¥" + info.getZkPrice());
        viewHolder.tv_price.setPaintFlags(viewHolder.tv_price.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
 
        if (info.getGoodsType() != Constant.GOODS_TYPE_VIP) {
            viewHolder.tv_sale_num.setText(info.getSalesType() == 1 ? "月销 " + info.getSalesCount() :
                    info.getSalesType() == 2 ? "2小时销量 " + info.getSalesCount() : info.getSalesType() == 3 ?
                            "今日销量 " + info.getSalesCount() : "总销量 " + info.getSalesCount());
        } else {
            viewHolder.tv_sale_num.setText("");
        }
 
//        info.setShopInfo(null);
        if (viewHolder.tv_shop_name != null) {
            if (info.getShopInfo() != null) {
                viewHolder.tv_shop_name.setVisibility(View.VISIBLE);
                viewHolder.tv_shop_name.setText(info.getShopInfo().getShopName());
            } else {
                viewHolder.tv_shop_name.setVisibility(View.GONE);
            }
        }
 
        //返利
        if (info.getMoneyInfo().getFanliMoney() != null) {
            viewHolder.tv_fanli_amount.setText("-" + info.getMoneyInfo().getFanliMoney());
            viewHolder.tv_fanli_amount.setVisibility(View.VISIBLE);
        } else {
            viewHolder.tv_fanli_amount.setVisibility(View.GONE);
        }
 
        if (info.getMoneyInfo().getHongBaoMoney() != null) {
            viewHolder.tv_hongbao_amount.setText("-" + info.getMoneyInfo().getHongBaoMoney());
            viewHolder.tv_hongbao_amount.setVisibility(View.VISIBLE);
        } else {
            viewHolder.tv_hongbao_amount.setVisibility(View.GONE);
        }
 
 
        String disCount = info.getMoneyInfo().getFinalMoney();
        if (info.isHasCoupon()) {
            if (StringUtils.isNullOrEmpty(disCount))
                disCount = "¥" + info.getCouponPrice();
            viewHolder.tv_coupon_amount.setVisibility(View.VISIBLE);
            viewHolder.tv_coupon_amount.setText("-¥" + info.getCouponInfo().getAmount());
        } else {
            if (StringUtils.isNullOrEmpty(disCount))
                if (info.getGoodsType() == Constant.GOODS_TYPE_VIP) {
                    disCount = "¥" + info.getCouponPrice();
                } else
                    disCount = "¥" + info.getZkPrice();
            viewHolder.tv_coupon_amount.setVisibility(View.GONE);
        }
 
        int startIndex = disCount.indexOf(".");
        if (startIndex > -1) {
            viewHolder.tv_actual_price1.setText(disCount.substring(0, startIndex + 1));
 
 
            viewHolder.tv_actual_price2.setText(disCount.substring(startIndex + 1));
        } else {
            viewHolder.tv_actual_price2.setText("");
            viewHolder.tv_actual_price1.setText(disCount);
        }
 
        SpannableString spannableString = new SpannableString(viewHolder.tv_actual_price1.getText());
        spannableString.setSpan(new RelativeSizeSpan(0.5f), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        viewHolder.tv_actual_price1.setText(spannableString);
 
 
        viewHolder.tv_sale_num.setTextColor((info.getSalesType() == 1 || info.getSalesType() == 4) ?
                mContext.getResources().getColor(R.color.gray5) : info.getSalesType() == 2 ?
                mContext.getResources().getColor(R.color.goods_sale_num_text_color_orange) :
                mContext.getResources().getColor(R.color.goods_sale_num_text_color_blue));
    }
 
}