Skip to content

Commit 99de245

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Respect child drawing order when dispatching touch events" into jb-mr1-dev
2 parents b365589 + a6478a3 commit 99de245

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

core/java/android/view/ViewGroup.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,8 +1723,10 @@ protected boolean dispatchGenericPointerEvent(MotionEvent event) {
17231723
final float x = event.getX();
17241724
final float y = event.getY();
17251725

1726+
final boolean customOrder = isChildrenDrawingOrderEnabled();
17261727
for (int i = childrenCount - 1; i >= 0; i--) {
1727-
final View child = children[i];
1728+
final int childIndex = customOrder ? getChildDrawingOrder(childrenCount, i) : i;
1729+
final View child = children[childIndex];
17281730
if (!canViewReceivePointerEvents(child)
17291731
|| !isTransformedTouchPointInView(x, y, child, null)) {
17301732
continue;
@@ -1851,8 +1853,11 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
18511853
final float x = ev.getX(actionIndex);
18521854
final float y = ev.getY(actionIndex);
18531855

1856+
final boolean customOrder = isChildrenDrawingOrderEnabled();
18541857
for (int i = childrenCount - 1; i >= 0; i--) {
1855-
final View child = children[i];
1858+
final int childIndex = customOrder ?
1859+
getChildDrawingOrder(childrenCount, i) : i;
1860+
final View child = children[childIndex];
18561861
if (!canViewReceivePointerEvents(child)
18571862
|| !isTransformedTouchPointInView(x, y, child, null)) {
18581863
continue;
@@ -1870,7 +1875,7 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
18701875
if (dispatchTransformedTouchEvent(ev, false, child, idBitsToAssign)) {
18711876
// Child wants to receive touch within its bounds.
18721877
mLastTouchDownTime = ev.getDownTime();
1873-
mLastTouchDownIndex = i;
1878+
mLastTouchDownIndex = childIndex;
18741879
mLastTouchDownX = ev.getX();
18751880
mLastTouchDownY = ev.getY();
18761881
newTouchTarget = addTouchTarget(child, idBitsToAssign);

0 commit comments

Comments
 (0)