This is the code I made for my onTouchListener:
if(event.getAction() == MotionEvent.ACTION_UP) {
Log.i("", "double touch : " + timeLastTouch + "... time passed: " + (System.currentTimeMillis() - timeLastTouch));
if (System.currentTimeMillis() - timeLastTouch < 500) {
Log.i("", "double touch TRUE");
timeLastTouch = System.currentTimeMillis();
return true;
} else {
Log.i("", "double touch FALSE");
timeLastTouch = System.currentTimeMillis();
return false;
}
}else if(event.getAction() == MotionEvent.ACTION_DOWN) {
Log.i("", "double touch DOWN : " + timeLastTouch + "... time passed: " + (System.currentTimeMillis() - timeLastTouch));
if (System.currentTimeMillis() - timeLastTouch < 500) {
Log.i("", "double touch TRUE DOWN");
timeLastTouch = System.currentTimeMillis();
return true;
}else {
Log.i("", "double touch FALSE DOWN");
return false;
}
}else {
timeLastTouch = System.currentTimeMillis();
Log.i("","double touch ELSE FALSE");
return false;
}
But it doesn't work. This view is over a Surface view. Now I only need to send the events to the SurfaceView for pinching (pinch to zoom) Now I tried to make the logic, so that if it has double touch, then I return true (it has consumed the touch, so then the surface view, doesn't get the touch). BUT if I do this, the pinch to zoom doesn't work neither. If I remove this logic, pinch zoom, works, so I added some logs, and followed them. I noticed that for pinch zoom, you get 2 down events, and only after the ACTION_MOVE is being called. Presumably, because when you pinch to zoom, you put down 2 fingers, and then zoom. MY problem is that my code was setting it, for the second Action_down to consume the touch, which means the pinch to zoom doesn't start. Any ideeas how to fix this?