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
package com.tejia.lijin.app.ui.dialog;
 
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.SeekBar;
import android.widget.TextView;
 
import com.wpc.library.util.SystemCommon;
import com.wpc.library.util.common.StringUtils;
import com.tejia.lijin.app.R;
import com.tejia.lijin.app.util.view.VerificationSeekBar;
 
/**
 * Created by weikou2015 on 2017/2/28.
 */
 
public class VerifyMobileDialog extends Dialog {
 
    public VerifyMobileDialog(Context context) {
        super(context);
        this.setCancelable(false);
    }
 
    public VerifyMobileDialog(Context context, int theme) {
        super(context, theme);
        this.setCancelable(false);
    }
 
 
    public static class Builder {
        private Context mContext;
        String message;
        String title;
        String mobileNum;
        private String positiveButtonText;
        private String negativeButtonText;
        private OnClickListener positiveButtonClickListener;
        private OnClickListener negativeButtonClickListener;
 
        public Builder(Context context) {
            this.mContext = context;
        }
 
        public Builder setMessage(String message) {
            this.message = message;
            return this;
        }
 
        public Builder setTitle(String title) {
            this.title = title;
            return this;
        }
 
        public Builder setMobileNum(String mobileNum) {
            this.mobileNum = mobileNum;
            return this;
        }
 
        /**
         * Set the positive button resource and it's listener
         *
         * @param positiveButtonText
         * @return
         */
        public Builder setPositiveButton(int positiveButtonText,
                                         OnClickListener listener) {
            this.positiveButtonText = (String) mContext
                    .getText(positiveButtonText);
            this.positiveButtonClickListener = listener;
            return this;
        }
 
        public Builder setPositiveButton(String positiveButtonText,
                                         OnClickListener listener) {
            this.positiveButtonText = positiveButtonText;
            this.positiveButtonClickListener = listener;
            return this;
        }
 
        public Builder setNegativeButton(int negativeButtonText,
                                         OnClickListener listener) {
            this.negativeButtonText = (String) mContext
                    .getText(negativeButtonText);
            this.negativeButtonClickListener = listener;
            return this;
        }
 
        public Builder setNegativeButton(String negativeButtonText,
                                         OnClickListener listener) {
            this.negativeButtonText = negativeButtonText;
            this.negativeButtonClickListener = listener;
            return this;
        }
 
        public VerifyMobileDialog create() {
            LayoutInflater inflater = (LayoutInflater) mContext
                    .getSystemService(mContext.LAYOUT_INFLATER_SERVICE);
            // instantiate the dialog with the custom Theme
            final VerifyMobileDialog dialog = new VerifyMobileDialog(mContext, R.style.Dialog);
            View layout = inflater.inflate(R.layout.dialog_verify_mobile, null);
            dialog.addContentView(layout, new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
            TextView tv_title = layout.findViewById(R.id.tv_title);
            if (!StringUtils.isEmpty(title))
                tv_title.setText(title);
            SeekBar seekbar = (VerificationSeekBar) layout.findViewById(R.id.sb_progress);
 
            seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
 
                }
 
                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
 
                }
 
                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                    if (seekBar.getProgress() != seekBar.getMax()) {
                        seekBar.setProgress(0);
                    } else {
                        if (positiveButtonClickListener != null) {
                            positiveButtonClickListener.onClick(dialog,
                                    DialogInterface.BUTTON_POSITIVE);
                        }
                    }
                }
            });
            // set the confirm button
            if (negativeButtonClickListener != null) {
                layout.findViewById(R.id.iv_cancle)
                        .setOnClickListener(new View.OnClickListener() {
                            public void onClick(View v) {
                                negativeButtonClickListener.onClick(dialog,
                                        DialogInterface.BUTTON_NEGATIVE);
                            }
                        });
            }
            dialog.setContentView(layout);
 
            android.view.WindowManager.LayoutParams params = dialog.getWindow()
                    .getAttributes();
            params.width = (int) ((SystemCommon.getScreenWidth(mContext) * 3) / 4);
            params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
            dialog.getWindow().
 
                    setAttributes(params);
            return dialog;
        }
    }
}