OSDN Git Service

Fixing crash during rotation
authorSunny Goyal <sunnygoyal@google.com>
Thu, 11 Feb 2016 18:07:36 +0000 (10:07 -0800)
committerSunny Goyal <sunnygoyal@google.com>
Thu, 11 Feb 2016 19:06:43 +0000 (11:06 -0800)
> Different views with same IDs were saving state
> Fixing scroll getting reset on rotation

Change-Id: Iae42419b83ee5ffa1bb43959f0931c8dfb761f32

res/layout/all_apps.xml
src/com/android/launcher3/allapps/AllAppsContainerView.java
src/com/android/launcher3/allapps/AlphabeticalAppsList.java

index c2b1e6f..a677fff 100644 (file)
@@ -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"
index 8f8858f..945125b 100644 (file)
@@ -587,16 +587,18 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
     @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();
index dac0df1..26e9231 100644 (file)
@@ -278,11 +278,14 @@ public class AlphabeticalAppsList {
     /**
      * 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;
     }
 
     /**