admin
2022-08-09 399ac289f80b7a40aa4210341db6b447cacdcf14
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package com.tejia.lijin.app.ui.dialog;
 
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
 
import com.tejia.lijin.app.R;
import com.tejia.lijin.app.entity.CouponInfo;
import com.tejia.lijin.app.entity.goods.GoodsDetailVO;
import com.tejia.lijin.app.entity.recommendinfo.ConvertLinkInfo;
import com.tejia.lijin.app.entity.user.VIPUpgradedNotify;
import com.tejia.lijin.app.ui.goods.GoodsDetailHongBaoListAdapter;
import com.tejia.lijin.app.ui.invite.ShareBrowserActivity;
import com.wpc.library.recyclerviewhelper.DividerItemDecoration;
import com.wpc.library.util.common.DimenUtils;
import com.wpc.library.util.common.StringUtils;
 
import java.util.ArrayList;
import java.util.List;
 
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
 
/**
 * 转链
 * Created by weikou2015 on 2017/2/28.
 */
 
public class GoodsDetailHongBaoAndCouponSelectDialog extends Dialog {
 
    public GoodsDetailHongBaoAndCouponSelectDialog(Context context) {
        super(context);
        this.setCancelable(false);
    }
 
    public GoodsDetailHongBaoAndCouponSelectDialog(Context context, int theme) {
        super(context, theme);
        this.setCancelable(false);
    }
 
    public static class Builder {
        private List<GoodsDetailVO.GoodsHongBaoListVO> hongBaoList;
        private List<CouponInfo> couponInfoList;
        private Context context;
        private OnItemClickListener itemClickListener;
 
 
        public Builder setHongBaoList(List<GoodsDetailVO.GoodsHongBaoListVO> hongBaoList) {
            this.hongBaoList = hongBaoList;
            return this;
        }
 
        public Builder setCouponList(List<CouponInfo> couponInfoList) {
            this.couponInfoList = couponInfoList;
            return this;
        }
 
        public Builder setItemClickListener(OnItemClickListener itemClickListener) {
            this.itemClickListener = itemClickListener;
            return this;
        }
 
 
        public Builder(Context context) {
            this.context = context;
        }
 
 
        public GoodsDetailHongBaoAndCouponSelectDialog create() {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final GoodsDetailHongBaoAndCouponSelectDialog dialog = new GoodsDetailHongBaoAndCouponSelectDialog(context, R.style.Dialog1);
            dialog.setCanceledOnTouchOutside(true);
            View layout = inflater.inflate(R.layout.dialog_goods_detail_hongbao_and_coupon, null);
            RecyclerView rv = layout.findViewById(R.id.rv_content);
            TextView tv_title = layout.findViewById(R.id.tv_title);
            TextView tv_cancel = layout.findViewById(R.id.tv_cancel);
 
            rv.setLayoutManager(new LinearLayoutManager(context));
            DividerItemDecoration decoration = new DividerItemDecoration();
            decoration.setSize(DimenUtils.dip2px(context, 4));
            rv.addItemDecoration(decoration);
 
            boolean hongBao = true;
            if ((hongBaoList == null || hongBaoList.size() == 0) && couponInfoList != null && couponInfoList.size() > 0) {
                hongBao = false;
                hongBaoList = new ArrayList<>();
                for (CouponInfo couponInfo : couponInfoList) {
                    GoodsDetailVO.GoodsHongBaoListVO vo = new GoodsDetailVO.GoodsHongBaoListVO();
                    vo.setSubMoney("¥" + couponInfo.getAmount());
                    String info = "";
                    if (StringUtils.isNullOrEmpty(couponInfo.getStartFee())) {
                        info = "(无门槛领取)";
                    } else {
                        info = String.format("(满%s减%s)", couponInfo.getStartFee(), couponInfo.getAmount());
                    }
                    vo.setSubMoneyDesc(info);
                    hongBaoList.add(vo);
                }
            }
 
            if (hongBao) {
                tv_title.setTextColor(Color.parseColor("#FF2C4A"));
            } else {
                tv_title.setTextColor(Color.parseColor("#FF7800"));
            }
 
 
            rv.setAdapter(new GoodsDetailHongBaoListAdapter(context, hongBaoList, new GoodsDetailHongBaoListAdapter.ListClickListener() {
 
                @Override
                public void onHongBaoClick(int p, GoodsDetailVO.GoodsHongBaoListVO info) {
                    itemClickListener.onClick(p);
                }
 
                @Override
                public void onCouponClick(int p) {
                    itemClickListener.onClick(p);
                }
            },
                    true, hongBao));
 
 
            tv_cancel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (dialog.isShowing())
                        dialog.dismiss();
                }
            });
 
 
            dialog.addContentView(layout, new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
 
            android.view.WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
            params.width = android.view.WindowManager.LayoutParams.MATCH_PARENT;
            params.height = WindowManager.LayoutParams.WRAP_CONTENT;
            dialog.getWindow().setAttributes(params);
            dialog.getWindow().setGravity(Gravity.BOTTOM);
            dialog.setCanceledOnTouchOutside(false);
            return dialog;
        }
 
 
    }
 
    public static interface OnItemClickListener {
        public void onClick(int p);
 
    }
}