OSDN Git Service

Preserve ResolverDrawerLayout fully collapsed state across relayout
authorAdam Powell <adamp@google.com>
Fri, 15 May 2015 20:39:22 +0000 (13:39 -0700)
committerAdam Powell <adamp@google.com>
Fri, 15 May 2015 20:59:40 +0000 (13:59 -0700)
Fix a bug where a relayout that grows the size of ResolverDrawerLayout
content would cause it to get stuck in a half-collapsed state. This
could also lead to janky touch interaction behavior in
onStopNestedScroll as it animates to the fully open/closed state after
clicking in a descendant list.

Bug 21202727

Change-Id: I5f0a8b19fc079c57fcf2be7c6fa7627b1cb12a3c

core/java/com/android/internal/widget/ResolverDrawerLayout.java

index 01e835b..be727f1 100644 (file)
@@ -661,13 +661,20 @@ public class ResolverDrawerLayout extends ViewGroup {
             }
         }
 
+        final int oldCollapsibleHeight = mCollapsibleHeight;
         mCollapsibleHeight = Math.max(0,
                 heightUsed - alwaysShowHeight - getMaxCollapsedHeight());
         mUncollapsibleHeight = heightUsed - mCollapsibleHeight;
 
         if (isLaidOut()) {
             final boolean isCollapsedOld = mCollapseOffset != 0;
-            mCollapseOffset = Math.min(mCollapseOffset, mCollapsibleHeight);
+            if (oldCollapsibleHeight < mCollapsibleHeight
+                    && mCollapseOffset == oldCollapsibleHeight) {
+                // Stay closed even at the new height.
+                mCollapseOffset = mCollapsibleHeight;
+            } else {
+                mCollapseOffset = Math.min(mCollapseOffset, mCollapsibleHeight);
+            }
             final boolean isCollapsedNew = mCollapseOffset != 0;
             if (isCollapsedOld != isCollapsedNew) {
                 notifyViewAccessibilityStateChangedIfNeeded(