From 6f4f7ffe03ead1a2efdd92950dd693d8fb74c893 Mon Sep 17 00:00:00 2001 From: Obolrom Date: Thu, 19 Sep 2024 15:30:55 +0300 Subject: [PATCH 1/2] Improve: remove unnecessary notifyDataSetChanged for ListAdapter --- .../amaze/filemanager/ui/views/appbar/SearchView.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 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 488df27a5c..545d0ce235 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 @@ -49,7 +49,6 @@ import android.animation.Animator; import android.animation.ObjectAnimator; -import android.annotation.SuppressLint; import android.content.Context; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; @@ -103,7 +102,6 @@ public class SearchView { private final AppCompatTextView deepSearchTV; private final ChipGroup recentChipGroup; - private final RecyclerView recyclerView; private final SearchRecyclerViewAdapter searchRecyclerViewAdapter; @@ -132,7 +130,6 @@ public class SearchView { private SortType sortType = defaultSortType; @SuppressWarnings("ConstantConditions") - @SuppressLint("NotifyDataSetChanged") public SearchView(final AppBar appbar, MainActivity mainActivity) { this.mainActivity = mainActivity; @@ -146,7 +143,7 @@ public SearchView(final AppBar appbar, MainActivity mainActivity) { recentHintTV = mainActivity.findViewById(R.id.searchRecentHintTV); searchResultsHintTV = mainActivity.findViewById(R.id.searchResultsHintTV); deepSearchTV = mainActivity.findViewById(R.id.searchDeepSearchTV); - recyclerView = mainActivity.findViewById(R.id.searchRecyclerView); + RecyclerView recyclerView = mainActivity.findViewById(R.id.searchRecyclerView); searchResultsSortHintTV = mainActivity.findViewById(R.id.searchResultsSortHintTV); searchResultsSortButton = mainActivity.findViewById(R.id.searchResultsSortButton); searchResultsSortAscDrawable = @@ -378,7 +375,6 @@ private void updateResultList(List newResults, String searchTerm) 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(); } @@ -614,10 +610,8 @@ private void initSearchViewColor(MainActivity a) { } } - @SuppressLint("NotifyDataSetChanged") private void clearRecyclerView() { - searchRecyclerViewAdapter.submitList(new ArrayList<>()); - searchRecyclerViewAdapter.notifyDataSetChanged(); + searchRecyclerViewAdapter.submitList(Collections.emptyList()); deepSearchTV.setVisibility(View.GONE); From f984a806d9e54879d80fe801bdf1df2ab0475b7f Mon Sep 17 00:00:00 2001 From: Obolrom Date: Sun, 29 Sep 2024 10:51:42 +0300 Subject: [PATCH 2/2] revert reduction of RV variable scope --- .../java/com/amaze/filemanager/ui/views/appbar/SearchView.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 545d0ce235..898eff2359 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 @@ -102,6 +102,7 @@ public class SearchView { private final AppCompatTextView deepSearchTV; private final ChipGroup recentChipGroup; + private final RecyclerView recyclerView; private final SearchRecyclerViewAdapter searchRecyclerViewAdapter; @@ -143,7 +144,7 @@ public SearchView(final AppBar appbar, MainActivity mainActivity) { recentHintTV = mainActivity.findViewById(R.id.searchRecentHintTV); searchResultsHintTV = mainActivity.findViewById(R.id.searchResultsHintTV); deepSearchTV = mainActivity.findViewById(R.id.searchDeepSearchTV); - RecyclerView recyclerView = mainActivity.findViewById(R.id.searchRecyclerView); + recyclerView = mainActivity.findViewById(R.id.searchRecyclerView); searchResultsSortHintTV = mainActivity.findViewById(R.id.searchResultsSortHintTV); searchResultsSortButton = mainActivity.findViewById(R.id.searchResultsSortButton); searchResultsSortAscDrawable =