diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-08 13:19:21 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-08 13:19:21 +0200 |
commit | 5406da40f427466b958cdd34bfeef22934c890df (patch) | |
tree | 5caebc8c9aa6509dd987671cbdbcf7b3df768759 /src/main/java/de/pixart/messenger/ui/interfaces/OnSwipeTouchListener.java | |
parent | f7c6c8399474aa11f7c07a2f84f2ab4db53748c1 (diff) |
make swipe to right gesture working
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/interfaces/OnSwipeTouchListener.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/interfaces/OnSwipeTouchListener.java | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/interfaces/OnSwipeTouchListener.java b/src/main/java/de/pixart/messenger/ui/interfaces/OnSwipeTouchListener.java deleted file mode 100644 index 716127c8c..000000000 --- a/src/main/java/de/pixart/messenger/ui/interfaces/OnSwipeTouchListener.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.pixart.messenger.ui.interfaces; - -import android.content.Context; -import android.util.Log; -import android.view.GestureDetector; -import android.view.MotionEvent; -import android.view.View; - -import de.pixart.messenger.Config; - -public class OnSwipeTouchListener implements View.OnTouchListener { - - private final GestureDetector gestureDetector; - - public OnSwipeTouchListener(Context context) { - gestureDetector = new GestureDetector(context, new GestureListener()); - } - - public void onSwipeLeft() { - } - - public void onSwipeRight() { - } - - public boolean onTouch(View v, MotionEvent event) { - return gestureDetector.onTouchEvent(event); - } - - private final class GestureListener extends GestureDetector.SimpleOnGestureListener { - - private static final int SWIPE_DISTANCE_THRESHOLD = 120; - private static final int SWIPE_VELOCITY_THRESHOLD = 200; - - @Override - public boolean onDown(MotionEvent e) { - return true; - } - - @Override - public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - if (e1 == null || e2 == null) { - Log.d(Config.LOGTAG, "Error MotionEvent"); - return false; - } - float distanceX = e2.getX() - e1.getX(); - float distanceY = e2.getY() - e1.getY(); - if (Math.abs(distanceX) > Math.abs(distanceY) && Math.abs(distanceX) > SWIPE_DISTANCE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) { - if (distanceX > 0) - onSwipeRight(); - else - onSwipeLeft(); - return true; - } - return false; - } - } -}
\ No newline at end of file |