diff options
author | Adam Powell <adamp@google.com> | 2010-02-18 11:35:13 -0800 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2010-02-18 15:53:59 -0800 |
commit | 45f2ca7f7d9fac55aa228e022f46ecbac8712a15 (patch) | |
tree | 5b027635b3421730c62d4e3e29f7ff4cda7152a0 /core | |
parent | bcbf564a3f527266693233cacd6728770d1a65fd (diff) | |
download | frameworks_base-45f2ca7f7d9fac55aa228e022f46ecbac8712a15.zip frameworks_base-45f2ca7f7d9fac55aa228e022f46ecbac8712a15.tar.gz frameworks_base-45f2ca7f7d9fac55aa228e022f46ecbac8712a15.tar.bz2 |
Recycle MotionEvents properly in GestureDetector
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/view/GestureDetector.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/java/android/view/GestureDetector.java b/core/java/android/view/GestureDetector.java index 58f998e..c1e1049 100644 --- a/core/java/android/view/GestureDetector.java +++ b/core/java/android/view/GestureDetector.java @@ -494,6 +494,9 @@ public class GestureDetector { mLastMotionX = x; mLastMotionY = y; + if (mCurrentDownEvent != null) { + mCurrentDownEvent.recycle(); + } mCurrentDownEvent = MotionEvent.obtain(ev); mAlwaysInTapRegion = true; mAlwaysInBiggerTapRegion = true; @@ -562,10 +565,14 @@ public class GestureDetector { if ((Math.abs(velocityY) > mMinimumFlingVelocity) || (Math.abs(velocityX) > mMinimumFlingVelocity)){ - handled = mListener.onFling(mCurrentDownEvent, currentUpEvent, velocityX, velocityY); + handled = mListener.onFling(mCurrentDownEvent, ev, velocityX, velocityY); } } - mPreviousUpEvent = MotionEvent.obtain(ev); + if (mPreviousUpEvent != null) { + mPreviousUpEvent.recycle(); + } + // Hold the event we obtained above - listeners may have changed the original. + mPreviousUpEvent = currentUpEvent; mVelocityTracker.recycle(); mVelocityTracker = null; mIsDoubleTapping = false; |