Skip to content

Commit

Permalink
* 优化密码页键盘开关逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
eritpchy committed Dec 7, 2022
1 parent ba36263 commit 2ba8707
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private void initView(Context context) {
mInputView.setFocusable(true);
mInputView.setFocusableInTouchMode(true);
mInputView.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
mInputView.setShowSoftInputOnFocus(true);
String packageName = context.getPackageName();
if (Constant.PACKAGE_NAME_ALIPAY.equals(packageName)
|| Constant.PACKAGE_NAME_TAOBAO.equals(packageName)
Expand Down Expand Up @@ -87,6 +88,14 @@ private void initView(Context context) {
this.addView(rootLLayout, rootLLayoutParams);

withPositiveButtonText(Lang.getString(R.id.ok));
withOnPositiveButtonClickListener((dialog, which) -> {
mInputView.clearFocus();
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mInputView.getWindowToken(), 0);
post(() -> {
dialog.dismiss();
});
});
}

@NonNull
Expand All @@ -107,10 +116,11 @@ public void setDefaultText(String text) {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
post(() -> {
mInputView.requestFocus();
postDelayed(() -> {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mInputView, InputMethodManager.SHOW_IMPLICIT);
});
}, 200);
}

@Override
Expand Down

0 comments on commit 2ba8707

Please sign in to comment.