Reputation: 33589
My app needs to detect simple gestures (scroll, tap, long tap), and pinch zoom. Either detector works fine on its own - GestureDetector.SimpleOnGestureListener
for tap / scroll and ScaleGestureDetector.SimpleOnScaleGestureListener
for pinch zoom. The problem is combining the two. More specifically, it is very hard to start pinch zoom so that a couple of onScroll
events are not generated before onScaleBegin
.
Is there any good way to fix this? The only solution I can think about is buffer a few events before processing them (event queue), and discard onScroll
/ onTap
without processing once onScaleBegin
is detected. But that would introduce input lag (which my app already has and I don't want to make it even worse).
Upvotes: 1
Views: 2473
Reputation: 24720
try this:
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean res = mScaleGestureDetector.onTouchEvent(event);
if (!mScaleGestureDetector.isInProgress()) {
res = mGestureDetector.onTouchEvent(event);
}
return res;
}
Upvotes: 3