am 6512cd28: Merge "Cancel update batch input timer only when point is added"

* commit '6512cd289d4d6bcc835b9da013c3098bf3807bc2':
  Cancel update batch input timer only when point is added
main
Tadashi G. Takaoka 2013-01-09 21:50:02 -08:00 committed by Android Git Automerger
commit 0e77caa1d0
2 changed files with 15 additions and 8 deletions

View File

@ -920,8 +920,12 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
final boolean isMajorEvent, final Key key) { final boolean isMajorEvent, final Key key) {
final int gestureTime = (int)(eventTime - sGestureFirstDownTime); final int gestureTime = (int)(eventTime - sGestureFirstDownTime);
if (mIsDetectingGesture) { if (mIsDetectingGesture) {
final int beforeLength = mGestureStrokeWithPreviewPoints.getLength();
final boolean onValidArea = mGestureStrokeWithPreviewPoints.addPointOnKeyboard( final boolean onValidArea = mGestureStrokeWithPreviewPoints.addPointOnKeyboard(
x, y, gestureTime, isMajorEvent); x, y, gestureTime, isMajorEvent);
if (mGestureStrokeWithPreviewPoints.getLength() > beforeLength) {
mTimerProxy.startUpdateBatchInputTimer(this);
}
// If the move event goes out from valid batch input area, cancel batch input. // If the move event goes out from valid batch input area, cancel batch input.
if (!onValidArea) { if (!onValidArea) {
cancelBatchInput(); cancelBatchInput();
@ -943,7 +947,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
if (DEBUG_MOVE_EVENT) { if (DEBUG_MOVE_EVENT) {
printTouchEvent("onMoveEvent:", x, y, eventTime); printTouchEvent("onMoveEvent:", x, y, eventTime);
} }
mTimerProxy.cancelUpdateBatchInputTimer(this);
if (mIsTrackingCanceled) { if (mIsTrackingCanceled) {
return; return;
} }

View File

@ -163,6 +163,10 @@ public class GestureStroke {
} }
} }
public int getLength() {
return mEventTimes.getLength();
}
public void onDownEvent(final int x, final int y, final long downTime, public void onDownEvent(final int x, final int y, final long downTime,
final long gestureFirstDownTime, final long lastTypingTime) { final long gestureFirstDownTime, final long lastTypingTime) {
reset(); reset();
@ -202,7 +206,7 @@ public class GestureStroke {
if (!hasDetectedFastMove()) { if (!hasDetectedFastMove()) {
return false; return false;
} }
final int size = mEventTimes.getLength(); final int size = getLength();
if (size <= 0) { if (size <= 0) {
return false; return false;
} }
@ -229,7 +233,7 @@ public class GestureStroke {
} }
public void duplicateLastPointWith(final int time) { public void duplicateLastPointWith(final int time) {
final int lastIndex = mEventTimes.getLength() - 1; final int lastIndex = getLength() - 1;
if (lastIndex >= 0) { if (lastIndex >= 0) {
final int x = mXCoordinates.get(lastIndex); final int x = mXCoordinates.get(lastIndex);
final int y = mYCoordinates.get(lastIndex); final int y = mYCoordinates.get(lastIndex);
@ -255,7 +259,7 @@ public class GestureStroke {
} }
private void appendPoint(final int x, final int y, final int time) { private void appendPoint(final int x, final int y, final int time) {
final int lastIndex = mEventTimes.getLength() - 1; final int lastIndex = getLength() - 1;
// The point that is created by {@link duplicateLastPointWith(int)} may have later event // The point that is created by {@link duplicateLastPointWith(int)} may have later event
// time than the next {@link MotionEvent}. To maintain the monotonicity of the event time, // time than the next {@link MotionEvent}. To maintain the monotonicity of the event time,
// drop the successive point here. // drop the successive point here.
@ -281,7 +285,7 @@ public class GestureStroke {
} }
private int detectFastMove(final int x, final int y, final int time) { private int detectFastMove(final int x, final int y, final int time) {
final int size = mEventTimes.getLength(); final int size = getLength();
final int lastIndex = size - 1; final int lastIndex = size - 1;
final int lastX = mXCoordinates.get(lastIndex); final int lastX = mXCoordinates.get(lastIndex);
final int lastY = mYCoordinates.get(lastIndex); final int lastY = mYCoordinates.get(lastIndex);
@ -321,7 +325,7 @@ public class GestureStroke {
*/ */
public boolean addPointOnKeyboard(final int x, final int y, final int time, public boolean addPointOnKeyboard(final int x, final int y, final int time,
final boolean isMajorEvent) { final boolean isMajorEvent) {
final int size = mEventTimes.getLength(); final int size = getLength();
if (size <= 0) { if (size <= 0) {
// Down event // Down event
appendPoint(x, y, time); appendPoint(x, y, time);
@ -348,7 +352,7 @@ public class GestureStroke {
final int pixelsPerSec = pixels * MSEC_PER_SEC; final int pixelsPerSec = pixels * MSEC_PER_SEC;
// Equivalent to (pixels / msecs < mGestureRecognitionThreshold / MSEC_PER_SEC) // Equivalent to (pixels / msecs < mGestureRecognitionThreshold / MSEC_PER_SEC)
if (pixelsPerSec < mGestureRecognitionSpeedThreshold * msecs) { if (pixelsPerSec < mGestureRecognitionSpeedThreshold * msecs) {
mIncrementalRecognitionSize = mEventTimes.getLength(); mIncrementalRecognitionSize = getLength();
} }
} }
@ -358,7 +362,7 @@ public class GestureStroke {
} }
public final void appendAllBatchPoints(final InputPointers out) { public final void appendAllBatchPoints(final InputPointers out) {
appendBatchPoints(out, mEventTimes.getLength()); appendBatchPoints(out, getLength());
} }
public final void appendIncrementalBatchPoints(final InputPointers out) { public final void appendIncrementalBatchPoints(final InputPointers out) {