Skip to content

Commit

Permalink
Null check RecyclerView references in search bar callbacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-signal authored and alex-signal committed Nov 16, 2022
1 parent fa02ee1 commit 13ed122
Showing 1 changed file with 9 additions and 5 deletions.
Expand Up @@ -661,23 +661,27 @@ public void onSearchTextChange(String text) {
viewModel.onSearchQueryUpdated(trimmed);

if (trimmed.length() > 0) {
if (activeAdapter != searchAdapter) {
if (activeAdapter != searchAdapter && list != null) {
setAdapter(searchAdapter);
list.removeItemDecoration(searchAdapterDecoration);
list.addItemDecoration(searchAdapterDecoration);
}
} else {
if (activeAdapter != defaultAdapter) {
list.removeItemDecoration(searchAdapterDecoration);
setAdapter(defaultAdapter);
if (list != null) {
list.removeItemDecoration(searchAdapterDecoration);
setAdapter(defaultAdapter);
}
}
}
}

@Override
public void onSearchClosed() {
list.removeItemDecoration(searchAdapterDecoration);
setAdapter(defaultAdapter);
if (list != null) {
list.removeItemDecoration(searchAdapterDecoration);
setAdapter(defaultAdapter);
}
requireCallback().onSearchClosed();
fadeInButtonsAndMegaphone(250);
}
Expand Down

0 comments on commit 13ed122

Please sign in to comment.