Recycle MotionEvents properly in GestureDetector

This commit is contained in:
Adam Powell
2010-02-18 11:35:13 -08:00
parent bcbf564a3f
commit 45f2ca7f7d

View File

@@ -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;