I set a breakpoint at one of the lines but it seems that it never stops at the break point, and I assume based on that that it simply wasn't triggered, here is the code:
final ImageView imageViewRoomButton = (ImageView) findViewById(R.id.imageView9);
final GestureDetector gdt = new GestureDetector(new GestureListener());
imageViewRoomButton.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(final View view, final MotionEvent event) {
gdt.onTouchEvent(event);
return true;
}
});
private class GestureListener extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onDown(MotionEvent event) {
return true;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
Toast toast1 = Toast.makeText(getApplicationContext(), "you just swiped up", Toast.LENGTH_LONG);
toast1.show();
if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
return true; // Right to left
} else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
return true; // Left to right
}
if(e1.getY() - e2.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
return true; // Bottom to top
} else if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
return true; // Top to bottom
}
return true;
}
}
I placed breakpoints in both onFling, onDown and onTouch, nothing happens.
Any suggestions?