am e56686f4: Merge "Cancel update batch input timer whenever MotionEvent is received"

* commit 'e56686f43af81db965941a393c5e0231c26ec77b':
  Cancel update batch input timer whenever MotionEvent is received
main
Tadashi G. Takaoka 2013-01-09 01:15:20 -08:00 committed by Android Git Automerger
commit b772cf7287
3 changed files with 24 additions and 0 deletions

View File

@ -365,6 +365,11 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
mGestureRecognitionUpdateTime); mGestureRecognitionUpdateTime);
} }
@Override
public void cancelUpdateBatchInputTimer(final PointerTracker tracker) {
removeMessages(MSG_UPDATE_BATCH_INPUT, tracker);
}
@Override @Override
public void cancelAllUpdateBatchInputTimers() { public void cancelAllUpdateBatchInputTimers() {
removeMessages(MSG_UPDATE_BATCH_INPUT); removeMessages(MSG_UPDATE_BATCH_INPUT);

View File

@ -98,6 +98,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
public boolean isInDoubleTapTimeout(); public boolean isInDoubleTapTimeout();
public void cancelKeyTimers(); public void cancelKeyTimers();
public void startUpdateBatchInputTimer(PointerTracker tracker); public void startUpdateBatchInputTimer(PointerTracker tracker);
public void cancelUpdateBatchInputTimer(PointerTracker tracker);
public void cancelAllUpdateBatchInputTimers(); public void cancelAllUpdateBatchInputTimers();
public static class Adapter implements TimerProxy { public static class Adapter implements TimerProxy {
@ -124,6 +125,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
@Override @Override
public void startUpdateBatchInputTimer(PointerTracker tracker) {} public void startUpdateBatchInputTimer(PointerTracker tracker) {}
@Override @Override
public void cancelUpdateBatchInputTimer(PointerTracker tracker) {}
@Override
public void cancelAllUpdateBatchInputTimers() {} public void cancelAllUpdateBatchInputTimers() {}
} }
} }
@ -940,6 +943,7 @@ 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;
} }
@ -1124,6 +1128,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
printTouchEvent("onUpEvent :", x, y, eventTime); printTouchEvent("onUpEvent :", x, y, eventTime);
} }
mTimerProxy.cancelUpdateBatchInputTimer(this);
if (!sInGesture) { if (!sInGesture) {
if (mCurrentKey != null && mCurrentKey.isModifier()) { if (mCurrentKey != null && mCurrentKey.isModifier()) {
// Before processing an up event of modifier key, all pointers already being // Before processing an up event of modifier key, all pointers already being

View File

@ -233,6 +233,10 @@ public class GestureStroke {
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);
if (DEBUG) {
Log.d(TAG, String.format("[%d] duplicateLastPointWith: %d,%d|%d", mPointerId,
x, y, time));
}
// TODO: Have appendMajorPoint() // TODO: Have appendMajorPoint()
appendPoint(x, y, time); appendPoint(x, y, time);
updateIncrementalRecognitionSize(x, y, time); updateIncrementalRecognitionSize(x, y, time);
@ -251,6 +255,16 @@ 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;
// 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,
// drop the successive point here.
if (lastIndex >= 0 && mEventTimes.get(lastIndex) > time) {
Log.w(TAG, String.format("[%d] drop stale event: %d,%d|%d last: %d,%d|%d", mPointerId,
x, y, time, mXCoordinates.get(lastIndex), mYCoordinates.get(lastIndex),
mEventTimes.get(lastIndex)));
return;
}
mEventTimes.add(time); mEventTimes.add(time);
mXCoordinates.add(x); mXCoordinates.add(x);
mYCoordinates.add(y); mYCoordinates.add(y);