1515import android .widget .ImageView ;
1616import android .widget .TextView ;
1717
18- import com .developer .progressx .ProgressWheel ;
19-
2018import java .util .Objects ;
2119
2220/**
@@ -29,7 +27,7 @@ public class KAlertDialog extends Dialog implements View.OnClickListener {
2927 public static final int WARNING_TYPE = 3 ;
3028 public static final int CUSTOM_IMAGE_TYPE = 4 ;
3129 public static final int PROGRESS_TYPE = 5 ;
32- public static final int EDIT_TEXT_TYPE = 6 ;
30+ public static final int INPUT_TYPE = 6 ;
3331 private static final int NORMAL_TYPE = 0 ;
3432 private final AnimationSet mModalInAnim , mModalOutAnim , mErrorXInAnim , mSuccessLayoutAnimSet ;
3533 private final Animation mOverlayOutAnim , mErrorInAnim , mSuccessBowAnim ;
@@ -73,14 +71,11 @@ public void onAnimationStart(Animation animation) {
7371 @ Override
7472 public void onAnimationEnd (Animation animation ) {
7573 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 ();
8479 }
8580 });
8681 }
@@ -98,6 +93,8 @@ protected void applyTransformation(float interpolatedTime, Transformation t) {
9893 }
9994 };
10095 mOverlayOutAnim .setDuration (120 );
96+
97+ Objects .requireNonNull (this .getWindow ()).setSoftInputMode (WindowManager .LayoutParams .SOFT_INPUT_STATE_ALWAYS_HIDDEN );
10198 }
10299
103100 protected void onCreate (Bundle savedInstanceState ) {
@@ -110,7 +107,7 @@ protected void onCreate(Bundle savedInstanceState) {
110107 mTitleTextView = findViewById (R .id .title_text );
111108 mContentTextView = findViewById (R .id .content_text );
112109 mErrorFrame = findViewById (R .id .error_frame );
113- mErrorX = mErrorFrame .findViewById (R .id .error_x );
110+ mErrorX = Objects . requireNonNull ( mErrorFrame ) .findViewById (R .id .error_x );
114111 mSuccessFrame = findViewById (R .id .success_frame );
115112 mProgressFrame = findViewById (R .id .progress_dialog );
116113 mSuccessTick = mSuccessFrame .findViewById (R .id .success_tick );
@@ -119,7 +116,7 @@ protected void onCreate(Bundle savedInstanceState) {
119116 mCustomImage = findViewById (R .id .custom_image );
120117 mWarningFrame = findViewById (R .id .warning_frame );
121118 mEditTextFrame = findViewById (R .id .edit_text_frame );
122- mProgressHelper .setProgressWheel (( ProgressWheel ) findViewById (R .id .progressWheel ));
119+ mProgressHelper .setProgressWheel (findViewById (R .id .progressWheel ));
123120
124121 mConfirmButton = findViewById (R .id .custom_confirm_button );
125122 mCancelButton = findViewById (R .id .cancel_button );
@@ -192,7 +189,7 @@ private void changeAlertType(int alertType, boolean fromCreate) {
192189 mConfirmButton .setVisibility (View .GONE );
193190 setConfirmButtonColor (mColor );
194191 break ;
195- case EDIT_TEXT_TYPE :
192+ case INPUT_TYPE :
196193 mEditText .requestFocus ();
197194 mEditTextFrame .setVisibility (View .VISIBLE );
198195 setConfirmButtonColor (mColor );
@@ -323,6 +320,14 @@ public KAlertDialog setContentText(String text) {
323320 return this ;
324321 }
325322
323+ public String getInputText () {
324+ return mEditText .getText ().toString ();
325+ }
326+
327+ public void setInputText (String text ) {
328+ mEditText .setText (text );
329+ }
330+
326331 public boolean isShowCancelButton () {
327332 return mShowCancel ;
328333 }
@@ -356,14 +361,6 @@ public KAlertDialog setConfirmText(String text) {
356361 return this ;
357362 }
358363
359- public String getInputText () {
360- return mEditText .getText ().toString ();
361- }
362-
363- public void setInputText (String text ) {
364- mEditText .setText (text );
365- }
366-
367364 public KAlertDialog confirmButtonColor (int color ) {
368365 return setConfirmButtonColor (getContext ().getResources ().getDrawable (color ));
369366 }
0 commit comments