Cancel update batch input timer whenever MotionEvent is received
Bug: 7911739 Change-Id: Id2cd98385371fd98435943ed66ec5381dfaa48e0
This commit is contained in:
parent
8315e8168b
commit
915f348b35
3 changed files with 24 additions and 0 deletions
|
@ -365,6 +365,11 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
|||
mGestureRecognitionUpdateTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelUpdateBatchInputTimer(final PointerTracker tracker) {
|
||||
removeMessages(MSG_UPDATE_BATCH_INPUT, tracker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelAllUpdateBatchInputTimers() {
|
||||
removeMessages(MSG_UPDATE_BATCH_INPUT);
|
||||
|
|
|
@ -98,6 +98,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
|||
public boolean isInDoubleTapTimeout();
|
||||
public void cancelKeyTimers();
|
||||
public void startUpdateBatchInputTimer(PointerTracker tracker);
|
||||
public void cancelUpdateBatchInputTimer(PointerTracker tracker);
|
||||
public void cancelAllUpdateBatchInputTimers();
|
||||
|
||||
public static class Adapter implements TimerProxy {
|
||||
|
@ -124,6 +125,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
|||
@Override
|
||||
public void startUpdateBatchInputTimer(PointerTracker tracker) {}
|
||||
@Override
|
||||
public void cancelUpdateBatchInputTimer(PointerTracker tracker) {}
|
||||
@Override
|
||||
public void cancelAllUpdateBatchInputTimers() {}
|
||||
}
|
||||
}
|
||||
|
@ -938,6 +941,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
|||
if (DEBUG_MOVE_EVENT) {
|
||||
printTouchEvent("onMoveEvent:", x, y, eventTime);
|
||||
}
|
||||
mTimerProxy.cancelUpdateBatchInputTimer(this);
|
||||
if (mIsTrackingCanceled) {
|
||||
return;
|
||||
}
|
||||
|
@ -1122,6 +1126,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
|||
printTouchEvent("onUpEvent :", x, y, eventTime);
|
||||
}
|
||||
|
||||
mTimerProxy.cancelUpdateBatchInputTimer(this);
|
||||
if (!sInGesture) {
|
||||
if (mCurrentKey != null && mCurrentKey.isModifier()) {
|
||||
// Before processing an up event of modifier key, all pointers already being
|
||||
|
|
|
@ -233,6 +233,10 @@ public class GestureStroke {
|
|||
if (lastIndex >= 0) {
|
||||
final int x = mXCoordinates.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()
|
||||
appendPoint(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) {
|
||||
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);
|
||||
mXCoordinates.add(x);
|
||||
mYCoordinates.add(y);
|
||||
|
|
Loading…
Reference in a new issue