Skip to content

Instantly share code, notes, and snippets.

@HugoGresse
Created November 20, 2015 08:49
Show Gist options
  • Save HugoGresse/d7fc6b654f6998e717de to your computer and use it in GitHub Desktop.
Save HugoGresse/d7fc6b654f6998e717de to your computer and use it in GitHub Desktop.
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
mStartNativeX = event.getX();
mStartNativeY = event.getY();
mIsNativeClick = true;
return true;
case MotionEvent.ACTION_MOVE:
if (mIsNativeClick && (Math.abs(mStartNativeX - event.getX()) > SCROLL_THRESHOLD
|| Math.abs(mStartNativeY - event.getY()) > SCROLL_THRESHOLD)) {
mIsNativeClick = false;
}
break;
case MotionEvent.ACTION_UP:
if (mIsNativeClick) {
// click listener here
return true;
}
break;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment