Fixing crash during rotation
> Different views with same IDs were saving state
> Fixing scroll getting reset on rotation
Change-Id: Iae42419b83ee5ffa1bb43959f0931c8dfb761f32
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index c2b1e6f..a677fff 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 @@
<LinearLayout
android:id="@+id/search_container"
android:layout_width="match_parent"
+ android:saveEnabled="false"
android:layout_height="@dimen/all_apps_search_bar_height"
android:layout_gravity="start|top"
android:orientation="horizontal"
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 8f8858f..945125b 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -587,16 +587,18 @@
@Override
public void onSearchResult(String query, ArrayList<ComponentKey> 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 dac0df1..26e9231 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -278,11 +278,14 @@
/**
* Sets the sorted list of filtered components.
*/
- public void setOrderedFilter(ArrayList<ComponentKey> f) {
+ public boolean setOrderedFilter(ArrayList<ComponentKey> f) {
if (mSearchResults != f) {
+ boolean same = mSearchResults != null && mSearchResults.equals(f);
mSearchResults = f;
updateAdapterItems();
+ return !same;
}
+ return false;
}
/**