Created
October 4, 2010 02:32
-
-
Save shirou/609182 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gesture detection | |
mGestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() { | |
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { | |
int dx = (int) (e2.getX() - e1.getX()); | |
// don't accept the fling if it's too short | |
// as it may conflict with a button push | |
if (Math.abs(dx) > MAJOR_MOVE && Math.abs(velocityX) > Math.absvelocityY)) { | |
if (velocityX > 0) { | |
moveRight(); | |
} else { | |
moveLeft(); | |
} | |
return true; | |
} else { | |
return false; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment