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
167
168
169
170
171
172
package com.tejia.lijin.app.ui.dialog;
 
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
 
import com.androidquery.AQuery;
import com.tejia.lijin.app.R;
import com.tejia.lijin.app.ui.invite.ShareBrowserActivity;
import com.tejia.lijin.app.util.Constant;
import com.tejia.lijin.app.util.ad.AdUtil;
import com.tejia.lijin.app.util.ad.ExpressAdContainer;
import com.tejia.lijin.app.util.ad.ExpressAdManager;
import com.tejia.lijin.app.util.ui.dialog.DialogUtil;
import com.wpc.library.util.SystemCommon;
import com.wpc.library.util.common.DimenUtils;
import com.wpc.library.util.common.StringUtils;
 
import java.util.List;
 
/**
 * Created by weikou2015 on 2017/2/28.
 */
 
public class GoodsDetailNotifyDialog extends Dialog {
    public GoodsDetailNotifyDialog(Context context) {
        super(context);
        this.setCancelable(false);
    }
 
 
    public GoodsDetailNotifyDialog(Context context, int theme) {
        super(context, theme);
        this.setCancelable(false);
    }
 
 
    public static class Builder {
        private Activity context;
        IDialogButtonClick dialogButtonClickListener;
        private String btnName;
        private String link;
        private Integer iconResourceId;
        private String message;
 
        public Builder(Activity context) {
            this.context = context;
        }
 
 
        public Builder setLeftBtnInfo(String btnName, String link) {
            this.btnName = btnName;
            this.link = link;
            return this;
        }
 
        public Builder setMessage(String message) {
            this.message = message;
            return this;
        }
 
 
        public Builder setIconResource(Integer resourceId) {
            this.iconResourceId = resourceId;
            return this;
        }
 
        public Builder setOnButtonClickListener(IDialogButtonClick dialogCloseListener) {
            this.dialogButtonClickListener = dialogCloseListener;
            return this;
        }
 
        public GoodsDetailNotifyDialog create() {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final GoodsDetailNotifyDialog dialog = new GoodsDetailNotifyDialog(context, R.style.Dialog);
            View layout = inflater.inflate(R.layout.dialog_goods_detail_notify, null);
            AQuery mAquery = new AQuery(layout);
            final TextView tv_create = mAquery.id(R.id.tv_create).getTextView();
            final TextView tv_fanli = mAquery.id(R.id.tv_fanli).getTextView();
            //icon_goods_detail_notify
            if (iconResourceId != null) {
                //隐藏
                mAquery.id(R.id.iv_icon).visibility(View.VISIBLE);
                mAquery.id(R.id.iv_icon).image(iconResourceId);
            } else {
                mAquery.id(R.id.iv_icon).visibility(View.GONE);
            }
 
            if (message != null) {
                mAquery.id(R.id.tv_message).text(message);
            }
 
 
            if (!StringUtils.isNullOrEmpty(btnName)) {
                tv_create.setVisibility(View.VISIBLE);
                tv_create.setText(btnName);
            } else {
                tv_create.setVisibility(View.GONE);
                tv_create.setText(btnName);
            }
 
 
            GradientDrawable gradientDrawable = new GradientDrawable();
            gradientDrawable.setStroke(1, Color.parseColor("#F53245"));
            gradientDrawable.setColor(Color.WHITE);
            gradientDrawable.setCornerRadius(DimenUtils.dip2px(context, 50));
            tv_create.setBackground(gradientDrawable);
 
            gradientDrawable = new GradientDrawable();
            gradientDrawable.setColor(Color.parseColor("#55BE00"));
            gradientDrawable.setCornerRadius(DimenUtils.dip2px(context, 50));
            tv_fanli.setBackground(gradientDrawable);
            tv_create.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (!StringUtils.isNullOrEmpty(link)) {
                        context.startActivity(new Intent(context, ShareBrowserActivity.class).putExtra("url", link));
                    }
                    if (dialogButtonClickListener != null)
                        dialogButtonClickListener.onLeftClick();
                }
            });
 
            tv_fanli.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (dialogButtonClickListener != null)
                        dialogButtonClickListener.onRightClick();
                }
            });
 
            mAquery.id(R.id.iv_close).clicked(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    DialogUtil.dismiss(dialog);
                }
            });
 
 
            dialog.addContentView(layout, new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
            dialog.setContentView(layout);
 
            android.view.WindowManager.LayoutParams params = dialog.getWindow()
                    .getAttributes();
            params.width = (int) ((SystemCommon.getScreenWidth(context) * 4) / 5);
            params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
            dialog.getWindow().setAttributes(params);
            dialog.setCanceledOnTouchOutside(false);
            return dialog;
        }
 
 
        public static interface IDialogButtonClick {
            public void onLeftClick();
 
            public void onRightClick();
        }
 
 
    }
 
 
}