OSDN Git Service

Fix divider touchable region
authorJorim Jaggi <jjaggi@google.com>
Wed, 6 Apr 2016 01:03:56 +0000 (18:03 -0700)
committerJorim Jaggi <jjaggi@google.com>
Wed, 6 Apr 2016 01:20:25 +0000 (01:20 +0000)
Make sure to update the touchable region whenever the layout
changes. The layout is wrong if the window is invisible during
the first layout.

Bug: 27854148
Change-Id: Ic0501eccf7b919d10491c6f5aa0c0f1765a07c52

packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java

index 601d910..3005535 100644 (file)
@@ -240,16 +240,6 @@ public class DividerView extends FrameLayout implements OnTouchListener,
     protected void onAttachedToWindow() {
         super.onAttachedToWindow();
         EventBus.getDefault().register(this);
-        getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
-
-            @Override
-            public void onGlobalLayout() {
-                getViewTreeObserver().removeOnGlobalLayoutListener(this);
-                mWindowManagerProxy.setTouchRegion(new Rect(mHandle.getLeft(), mHandle.getTop(),
-                        mHandle.getLeft() + mHandle.getWidth(),
-                        mHandle.getTop() + mHandle.getHeight()));
-            }
-        });
     }
 
     @Override
@@ -274,6 +264,15 @@ public class DividerView extends FrameLayout implements OnTouchListener,
         return super.onApplyWindowInsets(insets);
     }
 
+    @Override
+    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+        super.onLayout(changed, left, top, right, bottom);
+        if (changed) {
+            mWindowManagerProxy.setTouchRegion(new Rect(mHandle.getLeft(), mHandle.getTop(),
+                    mHandle.getRight(), mHandle.getBottom()));
+        }
+    }
+
     public void setWindowManager(DividerWindowManager windowManager) {
         mWindowManager = windowManager;
     }