Prevent NPE

This commit is contained in:
M66B
2023-10-26 08:51:33 +02:00
parent 2e409a5dd4
commit dfa35d4da4
5 changed files with 171 additions and 164 deletions

View File

@@ -271,25 +271,26 @@ public class FragmentAnswers extends FragmentBase {
}
});
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String newText) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
searching = newText;
adapter.search(newText);
if (searchView != null)
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String newText) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
searching = newText;
adapter.search(newText);
}
return true;
}
return true;
}
@Override
public boolean onQueryTextSubmit(String query) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
searching = query;
adapter.search(query);
@Override
public boolean onQueryTextSubmit(String query) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
searching = query;
adapter.search(query);
}
return true;
}
return true;
}
});
});
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
String sort = prefs.getString("answer_sort", "order");