|
@@ -22,8 +22,8 @@ public class OnSwipeTouchListener implements OnTouchListener {
|
|
|
|
|
|
private final class GestureListener extends SimpleOnGestureListener {
|
|
|
|
|
|
- private static final int SWIPE_THRESHOLD = 350;
|
|
|
- private static final int SWIPE_VELOCITY_THRESHOLD = 200;
|
|
|
+ private static final int SWIPE_THRESHOLD = 120;
|
|
|
+ private static final int SWIPE_VELOCITY_THRESHOLD = 150;
|
|
|
|
|
|
@Override
|
|
|
public boolean onDown(MotionEvent e) {
|
|
@@ -32,35 +32,23 @@ public class OnSwipeTouchListener implements OnTouchListener {
|
|
|
|
|
|
@Override
|
|
|
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
|
|
- boolean result = false;
|
|
|
+
|
|
|
try {
|
|
|
- float diffY = e2.getY() - e1.getY();
|
|
|
float diffX = e2.getX() - e1.getX();
|
|
|
- if (Math.abs(diffX) > Math.abs(diffY)) {
|
|
|
- if (Math.abs(diffX) > SWIPE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
|
|
|
- if (diffX > 0) {
|
|
|
- onSwipeRight();
|
|
|
- result = true;
|
|
|
- } else {
|
|
|
- onSwipeLeft();
|
|
|
- result = true;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (Math.abs(diffY) > SWIPE_THRESHOLD && Math.abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) {
|
|
|
- if (diffY > 0) {
|
|
|
- onSwipeBottom();
|
|
|
- result = true;
|
|
|
- } else {
|
|
|
- onSwipeTop();
|
|
|
- result = true;
|
|
|
- }
|
|
|
+
|
|
|
+ if (Math.abs(diffX) > SWIPE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
|
|
|
+ if (diffX > 0) {
|
|
|
+ onSwipeRight();
|
|
|
+ } else {
|
|
|
+ onSwipeLeft();
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception exception) {
|
|
|
exception.printStackTrace();
|
|
|
+ return false;
|
|
|
}
|
|
|
- return result;
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -69,10 +57,4 @@ public class OnSwipeTouchListener implements OnTouchListener {
|
|
|
|
|
|
public void onSwipeLeft() {
|
|
|
}
|
|
|
-
|
|
|
- public void onSwipeTop() {
|
|
|
- }
|
|
|
-
|
|
|
- public void onSwipeBottom() {
|
|
|
- }
|
|
|
}
|