Skip to content

Commit 08177e8

Browse files
committed
Fix Keyboard handling
1 parent 89e1d83 commit 08177e8

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

library/src/main/java/candybar/lib/fragments/WallpapersFragment.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,6 @@ public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflat
147147
View clearQueryButton = searchView.findViewById(R.id.clear_query_button);
148148

149149
searchInput.setHint(requireActivity().getResources().getString(R.string.search_wallpapers));
150-
searchInput.requestFocus();
151-
152-
new Handler(Looper.getMainLooper()).postDelayed(() -> {
153-
if (getActivity() != null) {
154-
SoftKeyboardHelper.openKeyboard(getActivity());
155-
}
156-
}, 1000);
157-
158150
searchInput.addTextChangedListener(new TextWatcher() {
159151
@Override
160152
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -183,14 +175,19 @@ public boolean onMenuItemActionExpand(MenuItem menuItem) {
183175
if (getActivity() != null) {
184176
SoftKeyboardHelper.openKeyboard(getActivity());
185177
}
186-
}, 1000);
178+
}, 300);
187179

188180
return true;
189181
}
190182

191183
@Override
192184
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
193185
searchInput.setText("");
186+
new Handler(Looper.getMainLooper()).postDelayed(() -> {
187+
if (getActivity() != null) {
188+
SoftKeyboardHelper.closeKeyboard(getActivity());
189+
}
190+
}, 300);
194191
return true;
195192
}
196193
});

0 commit comments

Comments
 (0)