Cleaned a bit the code + Fixed cross display bug

This commit is contained in:
Kilian Périsset 2020-01-23 15:54:09 +01:00
parent 938e4a6f44
commit 579140b7c4
No known key found for this signature in database
GPG key ID: 82E3444C03B10ECF
2 changed files with 13 additions and 20 deletions

View file

@ -790,13 +790,10 @@ public class FileDisplayActivity extends FileActivity
//focus the SearchView
if (!TextUtils.isEmpty(searchQuery)) {
searchView.post(new Runnable() {
@Override
public void run() {
searchView.setIconified(false);
searchView.setQuery(searchQuery, true);
searchView.clearFocus();
}
searchView.post(() -> {
searchView.setIconified(false);
searchView.setQuery(searchQuery, true);
searchView.clearFocus();
});
}
@ -815,12 +812,7 @@ public class FileDisplayActivity extends FileActivity
getListOfFilesFragment().refreshDirectory();
}
} else {
searchView.post(new Runnable() {
@Override
public void run() {
searchView.setQuery("", true);
}
});
searchView.post(() -> searchView.setQuery("", true));
}
return true;
});

View file

@ -219,23 +219,26 @@ public class ExtendedListFragment extends Fragment implements
}
}
searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> handler.postDelayed(() -> {
searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> handler.post(() -> {
if (getActivity() != null && !(getActivity() instanceof FolderPickerActivity)
&& !(getActivity() instanceof UploadFilesActivity)) {
setFabVisible(!hasFocus);
if (TextUtils.isEmpty(searchView.getQuery())) {
closeButton.setVisibility(View.INVISIBLE);
}
}
}, 100));
}));
closeButton.setOnClickListener(view -> {
searchView.setQuery("", true);
searchView.requestFocus();
searchView.onActionViewExpanded();
theTextArea.requestFocus();
InputMethodManager inputMethodManager =
(InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.showSoftInput(searchView, InputMethodManager.SHOW_FORCED);
inputMethodManager.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT);
}
});
@ -282,11 +285,9 @@ public class ExtendedListFragment extends Fragment implements
public boolean onQueryTextChange(final String query) {
// After 300 ms, set the query
closeButton.setVisibility(View.VISIBLE);
if (query.isEmpty()) {
closeButton.setVisibility(View.INVISIBLE);
} else {
closeButton.setVisibility(View.VISIBLE);
}
if (getFragmentManager() != null && getFragmentManager().