Merge "Move processing MotionEvent out from PointerTracker"

This commit is contained in:
Tadashi G. Takaoka 2011-07-10 14:24:26 -07:00 committed by Android (Google) Code Review
commit 952266674a
2 changed files with 19 additions and 34 deletions

View file

@ -557,7 +557,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
mOldKeyIndex = tracker.getKeyIndexOn(lastX, lastY); mOldKeyIndex = tracker.getKeyIndexOn(lastX, lastY);
tracker.onUpEvent(lastX, lastY, eventTime); tracker.onUpEvent(lastX, lastY, eventTime);
} else if (pointerCount == 1 && oldPointerCount == 1) { } else if (pointerCount == 1 && oldPointerCount == 1) {
tracker.onTouchEvent(action, x, y, eventTime); processMotionEvent(tracker, action, x, y, eventTime);
} else { } else {
Log.w(TAG, "Unknown touch panel behavior: pointer count is " + pointerCount Log.w(TAG, "Unknown touch panel behavior: pointer count is " + pointerCount
+ " (old " + oldPointerCount + ")"); + " (old " + oldPointerCount + ")");
@ -571,25 +571,29 @@ public class LatinKeyboardBaseView extends KeyboardView {
tracker.onMoveEvent((int)me.getX(i), (int)me.getY(i), eventTime); tracker.onMoveEvent((int)me.getX(i), (int)me.getY(i), eventTime);
} }
} else { } else {
final PointerTracker tracker = getPointerTracker(id); processMotionEvent(getPointerTracker(id), action, x, y, eventTime);
switch (action) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN:
tracker.onDownEvent(x, y, eventTime);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
tracker.onUpEvent(x, y, eventTime);
break;
case MotionEvent.ACTION_CANCEL:
tracker.onCancelEvent(x, y, eventTime);
break;
}
} }
return true; return true;
} }
private static void processMotionEvent(PointerTracker tracker, int action, int x, int y,
long eventTime) {
switch (action) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN:
tracker.onDownEvent(x, y, eventTime);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
tracker.onUpEvent(x, y, eventTime);
break;
case MotionEvent.ACTION_CANCEL:
tracker.onCancelEvent(x, y, eventTime);
break;
}
}
@Override @Override
public void closing() { public void closing() {
super.closing(); super.closing();

View file

@ -330,25 +330,6 @@ public class PointerTracker {
return onMoveKeyInternal(x, y); return onMoveKeyInternal(x, y);
} }
public void onTouchEvent(int action, int x, int y, long eventTime) {
switch (action) {
case MotionEvent.ACTION_MOVE:
onMoveEvent(x, y, eventTime);
break;
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN:
onDownEvent(x, y, eventTime);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
onUpEvent(x, y, eventTime);
break;
case MotionEvent.ACTION_CANCEL:
onCancelEvent(x, y, eventTime);
break;
}
}
public void onDownEvent(int x, int y, long eventTime) { public void onDownEvent(int x, int y, long eventTime) {
if (DEBUG_EVENT) if (DEBUG_EVENT)
printTouchEvent("onDownEvent:", x, y, eventTime); printTouchEvent("onDownEvent:", x, y, eventTime);