Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private float lastX;
- private float lastY;
- public boolean onTouch(View v, MotionEvent ev) {
- final float y = ev.getX();
- final float x = ev.getY();
- final int hs = ev.getHistorySize();
- final int ac = ev.getAction();
- switch(ac)
- {
- case MotionEvent.ACTION_DOWN:
- {
- this.lastX = x;
- this.lastY = y;
- Log.i("TEST", "Down at " + x + "/" + y + " (History size="+hs+")");
- return true;
- }
- case MotionEvent.ACTION_MOVE:
- {
- Log.i("TEST", "Move at " + x + "/" + y + ": Delta="+(lastX-x)+"/"+(lastY-y) + " (History size="+hs+")");
- this.lastX = x;
- this.lastY = y;
- return true;
- }
- case MotionEvent.ACTION_UP:
- {
- Log.i("TEST", "Up at " + x + "/" + y + " (History size="+hs+")");
- return true;
- }
- }
- }
- Down at 376.0/259.0 (History size=0)
- Move at 392.0/268.0: Delta=-16.0/-9.0 (History size=0)
- Move at 394.0/268.0: Delta=-2.0/0.0 (History size=0)
- Move at 395.0/269.0: Delta=-1.0/-1.0 (History size=0)
- Move at 394.0/268.0: Delta=1.0/1.0 (History size=0)
- Move at 396.0/269.0: Delta=-2.0/-1.0 (History size=0)
- Move at 399.0/271.0: Delta=-3.0/-2.0 (History size=1)
- Move at 401.0/272.0: Delta=-2.0/-1.0 (History size=0)
- Move at 403.0/273.0: Delta=-2.0/-1.0 (History size=0)
- Move at 404.0/273.0: Delta=-1.0/0.0 (History size=0)
- Move at 405.0/274.0: Delta=-1.0/-1.0 (History size=0)
- Move at 406.0/275.0: Delta=-1.0/-1.0 (History size=0)
- Up at 406.0/275.0 (History size=0)
- private static PointF touchScreenStartPtArr[] = new PointF[10];
- private static PointF touchScreenStopPtArr[] = new PointF[10];
- private static PointF touchScreenCurrPtArr[] = new PointF[10];
- OnTouchListener onTouchListenerMulti = new OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- int action = event.getAction() & MotionEvent.ACTION_MASK;
- int pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
- int fingerId = event.getPointerId(pointerIndex);
- switch (action) {
- case MotionEvent.ACTION_DOWN:
- case MotionEvent.ACTION_POINTER_DOWN:
- touchScreenStartPtArr[fingerId].x = event.getX(pointerIndex);
- touchScreenStartPtArr[fingerId].y = event.getY(pointerIndex);
- break;
- case MotionEvent.ACTION_UP:
- case MotionEvent.ACTION_POINTER_UP:
- case MotionEvent.ACTION_CANCEL:
- touchScreenStopPtArr[fingerId].x = event.getX(pointerIndex);
- touchScreenStopPtArr[fingerId].y = event.getX(pointerIndex);
- break;
- case MotionEvent.ACTION_MOVE:
- int pointerCount = event.getPointerCount();
- for (int i = 0; i < pointerCount; i++) {
- touchScreenCurrPtArr[fingerId].x = event.getX(i);
- touchScreenCurrPtArr[fingerId].y = event.getY(i);
- }
- break;
- }
- return true;
- }
- };
- Down at 387.29388/247.27272 (History size=0)
- Move at 387.29388/247.27272: Delta=0.0/0.0 (History size=0)
- Move at 387.29388/247.27272: Delta=0.0/0.0 (History size=0)
- Move at 387.29388/245.39589: Delta=0.0/1.876831 (History size=0)
- Move at 387.29388/244.92668: Delta=0.0/0.46920776 (History size=0)
- Move at 387.29388/244.45747: Delta=0.0/0.46920776 (History size=0)
- Move at 387.29388/243.98827: Delta=0.0/0.46920776 (History size=0)
- Move at 387.29388/243.51906: Delta=0.0/0.46920776 (History size=0)
- Move at 389.01614/243.51906: Delta=-1.7222595/0.0 (History size=0)
- Move at 389.8773/243.51906: Delta=-0.861145/0.0 (History size=0)
- Move at 389.8773/243.04985: Delta=0.0/0.46920776 (History size=0)
- Move at 390.73843/243.04985: Delta=-0.861145/0.0 (History size=0)
- Move at 390.73843/242.58064: Delta=0.0/0.46920776 (History size=0)
- Move at 391.59958/242.58064: Delta=-0.861145/0.0 (History size=0)
- Move at 391.59958/242.11143: Delta=0.0/0.46920776 (History size=0)
- Move at 392.46072/242.11143: Delta=-0.861145/0.0 (History size=0)
- Move at 392.46072/241.64223: Delta=0.0/0.46920776 (History size=0)
- Move at 393.32187/241.64223: Delta=-0.861145/0.0 (History size=0)
- Move at 394.183/241.64223: Delta=-0.861145/0.0 (History size=0)
- Move at 394.183/241.17302: Delta=0.0/0.46920776 (History size=0)
- Move at 395.04413/241.17302: Delta=-0.8611145/0.0 (History size=0)
- Move at 395.04413/242.11143: Delta=0.0/-0.9384155 (History size=0)
- Move at 395.04413/242.58064: Delta=0.0/-0.46920776 (History size=0)
- Up at 395.04413/242.58064 (History size=0)
Add Comment
Please, Sign In to add comment