So below I've got a GestureDetector, but the whole thing shows "Deprecated Constructor" in Eclipse..
I'm using it to detect flings and it works great but I'm unable to find a parallel constructor. The whole thing is deprecated. To what do I switch over to?
Anyways, here's the code:
mGestureDetector = new GestureDetector(
new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDown(MotionEvent e) {
return true;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2,
float velocityX, float velocityY) {
// Roll the ball in the direction of the fling
Direction mCommandedRollDirection = Direction.NONE;
if (Math.abs(velocityX) > Math.abs(velocityY)) {
if (velocityX < 0)
mCommandedRollDirection = Direction.LEFT;
else
mCommandedRollDirection = Direction.RIGHT;
} else {
if (velocityY < 0)
mCommandedRollDirection = Direction.UP;
else
mCommandedRollDirection = Direction.DOWN;
}
if (mCommandedRollDirection != Direction.NONE) {
mGameEngine.rollBall(mCommandedRollDirection);
}
return true;
}
});
mGestureDetector.setIsLongpressEnabled(false);
}
Clearly, I want the same functionality. So what new functions do I have to add (if any) and which constructor exactly do I need to use?
(Yes, I know about the Android dev docs but like I said I'm having trouble finding the newer version of what's-it-called-GestureDetector)
Thank you!
exchange for this:
GestureDetector gd = new GestureDetector(getActivity(), new OnGestureListener() {
Methods for the listener
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With