From de0a8a396b4ba30aa7a6358f03b56b4644684de7 Mon Sep 17 00:00:00 2001 From: Hammad Rafiq Date: Thu, 1 Aug 2024 10:25:22 +0500 Subject: [PATCH] SearchView UpdateResultList exception handled --- .../filemanager/ui/views/appbar/SearchView.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java b/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java index 1397fcaee0..488df27a5c 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java +++ b/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java @@ -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; @@ -372,11 +373,15 @@ private void resetSearchMode() { * @param searchTerm The search term that resulted in the search results */ private void updateResultList(List newResults, String searchTerm) { - ArrayList items = new ArrayList<>(newResults); - Collections.sort( - items, new SearchResultListSorter(DirSortBy.NONE_ON_TOP, sortType, searchTerm)); - searchRecyclerViewAdapter.submitList(items); - searchRecyclerViewAdapter.notifyDataSetChanged(); + if (newResults != null) { + ArrayList 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 */