Skip to content

Commit 311fc0b

Browse files
author
Selim Cinek
committed
Fixed a crash that could occur in the ObservableScrollView
Bug: 17644848 Change-Id: I771c27f9fee8c0d5edfbd21998ea015fd1d6f685
1 parent 89e0f09 commit 311fc0b

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class ObservableScrollView extends ScrollView {
3434
private float mLastX;
3535
private float mLastY;
3636
private boolean mBlockFlinging;
37+
private boolean mTouchCancelled;
3738

3839
public ObservableScrollView(Context context, AttributeSet attrs) {
3940
super(context, attrs);
@@ -87,9 +88,20 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
8788

8889
@Override
8990
public boolean dispatchTouchEvent(MotionEvent ev) {
90-
boolean isEndGuesture = (ev.getAction() == MotionEvent.ACTION_UP
91-
|| ev.getAction() == MotionEvent.ACTION_CANCEL);
92-
if (!mTouchEnabled && !isEndGuesture) {
91+
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
92+
if (!mTouchEnabled) {
93+
mTouchCancelled = true;
94+
return false;
95+
}
96+
mTouchCancelled = false;
97+
} else if (mTouchCancelled) {
98+
return false;
99+
} else if (!mTouchEnabled) {
100+
MotionEvent cancel = MotionEvent.obtain(ev);
101+
cancel.setAction(MotionEvent.ACTION_CANCEL);
102+
super.dispatchTouchEvent(ev);
103+
cancel.recycle();
104+
mTouchCancelled = true;
93105
return false;
94106
}
95107
return super.dispatchTouchEvent(ev);

0 commit comments

Comments
 (0)