Hide keyboard when clicking cancel button in dialogs for going to subreddit and user.

This commit is contained in:
Alex Ning 2021-07-22 20:12:21 +08:00
parent 0a5b5cb209
commit 9bb5bb9938
4 changed files with 40 additions and 8 deletions

View File

@ -1477,7 +1477,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
startActivity(subredditIntent);
})
.setNegativeButton(R.string.cancel, null)
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
}
})
.setOnDismissListener(dialogInterface -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
@ -1518,7 +1522,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
startActivity(userIntent);
})
.setNegativeButton(R.string.cancel, null)
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
}
})
.setOnDismissListener(dialogInterface -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);

View File

@ -649,7 +649,11 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
startActivity(subredditIntent);
})
.setNegativeButton(R.string.cancel, null)
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
}
})
.setOnDismissListener(dialogInterface -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
@ -690,7 +694,11 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
startActivity(userIntent);
})
.setNegativeButton(R.string.cancel, null)
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
}
})
.setOnDismissListener(dialogInterface -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);

View File

@ -1441,7 +1441,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
startActivity(subredditIntent);
})
.setNegativeButton(R.string.cancel, null)
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
}
})
.setOnDismissListener(dialogInterface -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
@ -1482,7 +1486,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
startActivity(userIntent);
})
.setNegativeButton(R.string.cancel, null)
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
}
})
.setOnDismissListener(dialogInterface -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);

View File

@ -1247,7 +1247,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
startActivity(subredditIntent);
})
.setNegativeButton(R.string.cancel, null)
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
}
})
.setOnDismissListener(dialogInterface -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
@ -1288,7 +1292,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
startActivity(userIntent);
})
.setNegativeButton(R.string.cancel, null)
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
}
})
.setOnDismissListener(dialogInterface -> {
if (imm != null) {
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);