I wrote a simple class that makes it easy to detect the swipe events - TOP, RIGHT, BOTTOM, LEFT.
1: Detect single swipe event
// Detect and consume specific events
// {Available methods} - detectTop, detectRight, detectBottom, detectLeft
SwipeEvents.detectTop(swipeElement, new SwipeEvents.SwipeSingleCallback() {
@Override
public void onSwipe() {
showToast("Swiped - detectTop");
}
});
2: Detect any of the swipe events with one callback.
SwipeEvents.detect( swipeElement, new SwipeEvents.SwipeCallback() {
@Override
public void onSwipeTop() {
//Swiped top
}
@Override
public void onSwipeRight() {
//Swiped right
}
@Override
public void onSwipeBottom() {
//Swiped bottom
}
@Override
public void onSwipeLeft() {
//Swiped left
}
});
Here is a blog post with the explanation on how to use: http://bmutinda.com/android-detect-swipe-events/
I have also created a Gist for the code snippets available here: https://gist.github.com/bmutinda/9578f70f1df9bd0687b8
Thanks.