diff options
| author | 2014-09-29 20:47:39 +0000 | |
|---|---|---|
| committer | 2014-09-29 20:47:39 +0000 | |
| commit | 6b44ae6e921ec6030274b96e88c6e5746c74d6c2 (patch) | |
| tree | fadeba14a28e012b527e8610c5fdc6496c305786 | |
| parent | a621a97f4a05891a514ba5343c9db04d125e1eb8 (diff) | |
| parent | 311fc0b399f01a79169ae69aea05556043a7d7df (diff) | |
am 311fc0b3: Fixed a crash that could occur in the ObservableScrollView
* commit '311fc0b399f01a79169ae69aea05556043a7d7df':
Fixed a crash that could occur in the ObservableScrollView
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java index b842a6ba348d..1186a330064d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java @@ -34,6 +34,7 @@ public class ObservableScrollView extends ScrollView { private float mLastX; private float mLastY; private boolean mBlockFlinging; + private boolean mTouchCancelled; public ObservableScrollView(Context context, AttributeSet attrs) { super(context, attrs); @@ -87,9 +88,20 @@ public class ObservableScrollView extends ScrollView { @Override public boolean dispatchTouchEvent(MotionEvent ev) { - boolean isEndGuesture = (ev.getAction() == MotionEvent.ACTION_UP - || ev.getAction() == MotionEvent.ACTION_CANCEL); - if (!mTouchEnabled && !isEndGuesture) { + if (ev.getAction() == MotionEvent.ACTION_DOWN) { + if (!mTouchEnabled) { + mTouchCancelled = true; + return false; + } + mTouchCancelled = false; + } else if (mTouchCancelled) { + return false; + } else if (!mTouchEnabled) { + MotionEvent cancel = MotionEvent.obtain(ev); + cancel.setAction(MotionEvent.ACTION_CANCEL); + super.dispatchTouchEvent(ev); + cancel.recycle(); + mTouchCancelled = true; return false; } return super.dispatchTouchEvent(ev); |