Skip to content

Commit

Permalink
SearchView UpdateResultList exception handled
Browse files Browse the repository at this point in the history
  • Loading branch information
hammadrfq3 committed Aug 1, 2024
1 parent 82275fe commit de0a8a3
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;

import androidx.appcompat.widget.AppCompatButton;
import androidx.appcompat.widget.AppCompatEditText;
Expand Down Expand Up @@ -372,11 +373,15 @@ private void resetSearchMode() {
* @param searchTerm The search term that resulted in the search results
*/
private void updateResultList(List<SearchResult> newResults, String searchTerm) {
ArrayList<SearchResult> items = new ArrayList<>(newResults);
Collections.sort(
items, new SearchResultListSorter(DirSortBy.NONE_ON_TOP, sortType, searchTerm));
searchRecyclerViewAdapter.submitList(items);
searchRecyclerViewAdapter.notifyDataSetChanged();
if (newResults != null) {
ArrayList<SearchResult> items = new ArrayList<>(newResults);
Collections.sort(
items, new SearchResultListSorter(DirSortBy.NONE_ON_TOP, sortType, searchTerm));
searchRecyclerViewAdapter.submitList(items);
searchRecyclerViewAdapter.notifyDataSetChanged();
} else {
Toast.makeText(mainActivity, "No search result found", Toast.LENGTH_SHORT).show();
}
}

/** show search view with a circular reveal animation */
Expand Down

0 comments on commit de0a8a3

Please sign in to comment.