From bb702584fa551fab8cffbb0ae5459d9efd16ce2a Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 11 Feb 2016 10:07:36 -0800 Subject: [PATCH] Fixing crash during rotation > Different views with same IDs were saving state > Fixing scroll getting reset on rotation Change-Id: Iae42419b83ee5ffa1bb43959f0931c8dfb761f32 --- res/layout/all_apps.xml | 2 ++ .../launcher3/allapps/AllAppsContainerView.java | 10 ++++++---- .../launcher3/allapps/AlphabeticalAppsList.java | 5 ++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml index c2b1e6fef8..a677fff984 100644 --- a/res/layout/all_apps.xml +++ b/res/layout/all_apps.xml @@ -39,6 +39,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/main_content" + android:saveEnabled="false" android:visibility="gone" android:layout_gravity="center" android:focusable="true" @@ -60,6 +61,7 @@ apps) { if (apps != null) { - mApps.setOrderedFilter(apps); + if (mApps.setOrderedFilter(apps)) { + mAppsRecyclerView.onSearchResultsChanged(); + } mAdapter.setLastSearchQuery(query); - mAppsRecyclerView.onSearchResultsChanged(); } } @Override public void clearSearchResult() { - mApps.setOrderedFilter(null); - mAppsRecyclerView.onSearchResultsChanged(); + if (mApps.setOrderedFilter(null)) { + mAppsRecyclerView.onSearchResultsChanged(); + } // Clear the search query mSearchQueryBuilder.clear(); diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java index dac0df12a7..26e9231523 100644 --- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java +++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java @@ -278,11 +278,14 @@ public class AlphabeticalAppsList { /** * Sets the sorted list of filtered components. */ - public void setOrderedFilter(ArrayList f) { + public boolean setOrderedFilter(ArrayList f) { if (mSearchResults != f) { + boolean same = mSearchResults != null && mSearchResults.equals(f); mSearchResults = f; updateAdapterItems(); + return !same; } + return false; } /**