15
15
import android .widget .ImageView ;
16
16
import android .widget .TextView ;
17
17
18
- import com .developer .progressx .ProgressWheel ;
19
-
20
18
import java .util .Objects ;
21
19
22
20
/**
@@ -29,7 +27,7 @@ public class KAlertDialog extends Dialog implements View.OnClickListener {
29
27
public static final int WARNING_TYPE = 3 ;
30
28
public static final int CUSTOM_IMAGE_TYPE = 4 ;
31
29
public static final int PROGRESS_TYPE = 5 ;
32
- public static final int EDIT_TEXT_TYPE = 6 ;
30
+ public static final int INPUT_TYPE = 6 ;
33
31
private static final int NORMAL_TYPE = 0 ;
34
32
private final AnimationSet mModalInAnim , mModalOutAnim , mErrorXInAnim , mSuccessLayoutAnimSet ;
35
33
private final Animation mOverlayOutAnim , mErrorInAnim , mSuccessBowAnim ;
@@ -73,14 +71,11 @@ public void onAnimationStart(Animation animation) {
73
71
@ Override
74
72
public void onAnimationEnd (Animation animation ) {
75
73
mDialogView .setVisibility (View .GONE );
76
- mDialogView .post (new Runnable () {
77
- @ Override
78
- public void run () {
79
- if (mCloseFromCancel ) {
80
- KAlertDialog .super .cancel ();
81
- } else {
82
- KAlertDialog .super .dismiss ();
83
- }
74
+ mDialogView .post (() -> {
75
+ if (mCloseFromCancel ) {
76
+ KAlertDialog .super .cancel ();
77
+ } else {
78
+ KAlertDialog .super .dismiss ();
84
79
}
85
80
});
86
81
}
@@ -98,6 +93,8 @@ protected void applyTransformation(float interpolatedTime, Transformation t) {
98
93
}
99
94
};
100
95
mOverlayOutAnim .setDuration (120 );
96
+
97
+ Objects .requireNonNull (this .getWindow ()).setSoftInputMode (WindowManager .LayoutParams .SOFT_INPUT_STATE_ALWAYS_HIDDEN );
101
98
}
102
99
103
100
protected void onCreate (Bundle savedInstanceState ) {
@@ -110,7 +107,7 @@ protected void onCreate(Bundle savedInstanceState) {
110
107
mTitleTextView = findViewById (R .id .title_text );
111
108
mContentTextView = findViewById (R .id .content_text );
112
109
mErrorFrame = findViewById (R .id .error_frame );
113
- mErrorX = mErrorFrame .findViewById (R .id .error_x );
110
+ mErrorX = Objects . requireNonNull ( mErrorFrame ) .findViewById (R .id .error_x );
114
111
mSuccessFrame = findViewById (R .id .success_frame );
115
112
mProgressFrame = findViewById (R .id .progress_dialog );
116
113
mSuccessTick = mSuccessFrame .findViewById (R .id .success_tick );
@@ -119,7 +116,7 @@ protected void onCreate(Bundle savedInstanceState) {
119
116
mCustomImage = findViewById (R .id .custom_image );
120
117
mWarningFrame = findViewById (R .id .warning_frame );
121
118
mEditTextFrame = findViewById (R .id .edit_text_frame );
122
- mProgressHelper .setProgressWheel (( ProgressWheel ) findViewById (R .id .progressWheel ));
119
+ mProgressHelper .setProgressWheel (findViewById (R .id .progressWheel ));
123
120
124
121
mConfirmButton = findViewById (R .id .custom_confirm_button );
125
122
mCancelButton = findViewById (R .id .cancel_button );
@@ -192,7 +189,7 @@ private void changeAlertType(int alertType, boolean fromCreate) {
192
189
mConfirmButton .setVisibility (View .GONE );
193
190
setConfirmButtonColor (mColor );
194
191
break ;
195
- case EDIT_TEXT_TYPE :
192
+ case INPUT_TYPE :
196
193
mEditText .requestFocus ();
197
194
mEditTextFrame .setVisibility (View .VISIBLE );
198
195
setConfirmButtonColor (mColor );
@@ -323,6 +320,14 @@ public KAlertDialog setContentText(String text) {
323
320
return this ;
324
321
}
325
322
323
+ public String getInputText () {
324
+ return mEditText .getText ().toString ();
325
+ }
326
+
327
+ public void setInputText (String text ) {
328
+ mEditText .setText (text );
329
+ }
330
+
326
331
public boolean isShowCancelButton () {
327
332
return mShowCancel ;
328
333
}
@@ -356,14 +361,6 @@ public KAlertDialog setConfirmText(String text) {
356
361
return this ;
357
362
}
358
363
359
- public String getInputText () {
360
- return mEditText .getText ().toString ();
361
- }
362
-
363
- public void setInputText (String text ) {
364
- mEditText .setText (text );
365
- }
366
-
367
364
public KAlertDialog confirmButtonColor (int color ) {
368
365
return setConfirmButtonColor (getContext ().getResources ().getDrawable (color ));
369
366
}
0 commit comments