@@ -44,7 +44,9 @@ public static BasePop.Builder showALertTypeA(Context _context, View _achor,
44
44
String _allColor , boolean _bCancelDismiss ,
45
45
OnEventListenner .OnAlertClickListenner _onAlertClickListenner ) {
46
46
return new Builder (_context )
47
- .create (_title , _message , _nagative , _positive , _allColor , _bCancelDismiss , _achor )
47
+ .create (_title , _message , _nagative ,
48
+ _positive , _allColor , _bCancelDismiss ,
49
+ false , _achor )
48
50
.showAlertA (_onAlertClickListenner );
49
51
}
50
52
@@ -66,7 +68,32 @@ public static BasePop.Builder showALertTypeA(Context _context, View _achor,
66
68
.create (_title , _message ,
67
69
_context .getResources ().getString (R .string .cancel ),
68
70
_context .getResources ().getString (R .string .ok ),
69
- _allColor , true , _achor )
71
+ _allColor , true ,
72
+ false , _achor )
73
+ .showAlertA (_onAlertClickListenner );
74
+ }
75
+
76
+ /**
77
+ * 显示警告弹窗(A类型警告弹窗) - 只有确定按钮
78
+ * @param _context
79
+ * @param _achor
80
+ * @param _title - 标题
81
+ * @param _message - 提示消息
82
+ * @param _allColor - 主题颜色 - 目前针对左右按钮
83
+ * @param _bOkDismiss - 点击确定是否消失弹窗
84
+ * @param _onAlertClickListenner
85
+ * @return
86
+ */
87
+ public static BasePop .Builder showALertTypeA (Context _context , View _achor ,
88
+ String _title , String _message ,
89
+ String _allColor , boolean _bOkDismiss ,
90
+ OnEventListenner .OnAlertClickListenner _onAlertClickListenner ) {
91
+ return new Builder (_context )
92
+ .create (_title , _message ,
93
+ "" ,
94
+ _context .getResources ().getString (R .string .ok ),
95
+ _allColor , true ,
96
+ _bOkDismiss , _achor )
70
97
.showAlertA (_onAlertClickListenner );
71
98
}
72
99
@@ -79,9 +106,10 @@ public static class Builder {
79
106
private WeakReference <Context > contextWeakReference ;
80
107
private BasePop .Builder builder = null ;
81
108
private String titleS , messageS ;
82
- private String nagativeS , positiveS ;
109
+ private String nagativeS = "" , positiveS ;
83
110
private String allColor ;
84
111
private boolean bCancelDismiss ;
112
+ private boolean bOkDismiss ;
85
113
86
114
public Builder (Context _context ) {
87
115
this .contextWeakReference = new WeakReference <>(_context );
@@ -90,13 +118,15 @@ public Builder(Context _context) {
90
118
public Builder create (String _title , String _message ,
91
119
String _nagative , String _positive ,
92
120
String _allColor , boolean _bCancelDismis ,
121
+ boolean _bOkDismiss ,
93
122
View _achor ) {
94
123
this .allColor = _allColor ;
95
124
this .titleS = _title ;
96
125
this .messageS = _message ;
97
126
this .positiveS = _positive ;
98
127
this .nagativeS = _nagative ;
99
128
this .bCancelDismiss = _bCancelDismis ;
129
+ this .bOkDismiss = _bOkDismiss ;
100
130
this .builder = new BasePop .Builder (contextWeakReference .get ())
101
131
.create (_achor )
102
132
.setOutsideTouchable (false )
@@ -120,9 +150,15 @@ public BasePop.Builder showAlertA(final OnEventListenner.OnAlertClickListenner _
120
150
TextView title = popView .findViewById (R .id .pa_title );
121
151
TextView message = popView .findViewById (R .id .pa_message );
122
152
TextView negativeTv = popView .findViewById (R .id .pa_negativeTv );
153
+ ConstraintLayout negative = popView .findViewById (R .id .pa_negative );
123
154
TextView positiveTv = popView .findViewById (R .id .pa_positiveTv );
124
155
125
- int windowW = ScreenUtil .getScreenW (contextWeakReference .get ()) * 3 / 4 ;
156
+ int windowW ;
157
+ if (null == nagativeS || nagativeS .equals ("" )){
158
+ windowW = ScreenUtil .getScreenW (contextWeakReference .get ()) * 1 / 2 ;
159
+ }else {
160
+ windowW = ScreenUtil .getScreenW (contextWeakReference .get ()) * 3 / 4 ;
161
+ }
126
162
///< 内容宽度为屏幕的3/4
127
163
ScreenUtil .setConstraintLayoutWH (alertContentRoot , windowW , -1 );
128
164
@@ -132,6 +168,10 @@ public BasePop.Builder showAlertA(final OnEventListenner.OnAlertClickListenner _
132
168
negativeTv .setText (nagativeS );
133
169
positiveTv .setText (positiveS );
134
170
171
+ if (null == nagativeS || nagativeS .equals ("" )){
172
+ negative .setVisibility (View .GONE );
173
+ }
174
+
135
175
///< 设置主题
136
176
negativeTv .setTextColor (Color .parseColor (allColor ));
137
177
positiveTv .setTextColor (Color .parseColor (allColor ));
@@ -158,6 +198,10 @@ public void onClick(View v) {
158
198
if (null != _onAlertClickListenner ){
159
199
_onAlertClickListenner .onClick (v , CALLBACK_TYPE .OK );
160
200
}
201
+
202
+ if (bOkDismiss && (null == nagativeS || nagativeS .equals ("" ))){
203
+ builder .dissmiss ();
204
+ }
161
205
}
162
206
});
163
207
builder .show (BasePopView .SIMPLE_GRAVITY .CENTER_IN_PARENT );
0 commit comments