admin
2024-07-03 a40e0e51331e5e6f69e8bed5940512b29150c7a9
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
package com.taoke.autopay.android.ui.dialog;
 
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
 
import com.taoke.autopay.android.R;
import com.taoke.autopay.android.utils.SystemUtil;
 
 
/**
 * Created by weikou2015 on 2017/2/28.
 */
 
public class PayCountLimitNotifyDialog extends Dialog {
 
    public PayCountLimitNotifyDialog(Context context) {
        super(context);
        this.setCancelable(false);
    }
 
    public PayCountLimitNotifyDialog(Context context, int theme) {
        super(context, theme);
        this.setCancelable(false);
    }
 
 
    public static class Builder {
        private Context context;
 
        String title;
        private String positiveButtonText;
        private OnClickListener positiveButtonClickListener;
 
        public Builder(Context context) {
            this.context = context;
        }
 
 
        public Builder setTitle(String title) {
            this.title = title;
            return this;
        }
 
        /**
         * Set the positive button resource and it's listener
         *
         * @param positiveButtonText
         * @return
         */
        public Builder setPositiveButton(int positiveButtonText,
                                         OnClickListener listener) {
            this.positiveButtonText = (String) context
                    .getText(positiveButtonText);
            this.positiveButtonClickListener = listener;
            return this;
        }
 
        public Builder setPositiveButton(String positiveButtonText,
                                         OnClickListener listener) {
            this.positiveButtonText = positiveButtonText;
            this.positiveButtonClickListener = listener;
            return this;
        }
 
        public PayCountLimitNotifyDialog create() {
 
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            // instantiate the dialog with the custom Theme
            final PayCountLimitNotifyDialog dialog = new PayCountLimitNotifyDialog(context, R.style.Dialog);
            View layout = inflater.inflate(R.layout.dialog_pay_count_limit_notify, null);
            dialog.addContentView(layout, new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
            layout.findViewById(R.id.button)
                    .setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {
                            dialog.dismiss();
                            if(positiveButtonClickListener!=null){
                                positiveButtonClickListener.onClick(dialog,0);
                            }
                        }
                    });
            layout.findViewById(R.id.iv_clode)
                    .setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {
                            dialog.dismiss();
                        }
                    });
 
            dialog.setContentView(layout);
 
            android.view.WindowManager.LayoutParams params = dialog.getWindow()
                    .getAttributes();
            params.width = (int) ((SystemUtil.getScreenWidth(context) * 3) / 4);
            params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
            dialog.getWindow().setAttributes(params);
            return dialog;
        }
    }
}