Advertisement
moonlightcheese

Untitled

Apr 19th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. mGestureDetector = new GestureDetector(getActivity(), new GestureDetector.SimpleOnGestureListener() {
  2.     public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
  3.         Log.i(LOG_TAG, "flip gesture");
  4.         try {
  5.             Log.i(LOG_TAG, "e1: " + e1.toString() + "  || e2: " + e2.toString());
  6.             if(velocityY > -500 && velocityY < 500) {
  7.                 if(velocityX < 0) {
  8.                     //flip from right to left
  9.                     Log.i(LOG_TAG, "flip gesture, right to left");
  10.                     mViewFlipper.showNext();
  11.                     return true;
  12.                 } else if(velocityX > 0) {
  13.                     //flip from left to right
  14.                     Log.i(LOG_TAG, "flip gesture, left to right");
  15.                     mViewFlipper.showPrevious();
  16.                     return true;
  17.                 }
  18.             }
  19.         } catch(Exception e) {
  20.             Log.d(LOG_TAG, "wow... this is bad, something went wrong with paging gestures");
  21.         }
  22.         return false;
  23.     }
  24.     public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
  25.         Log.i(LOG_TAG, "scroll gesture");
  26.         return false;
  27.     }
  28.     public boolean onDown(MotionEvent e) {
  29.         Log.i(LOG_TAG, "Down: "+e.toString());
  30.         return false;
  31.     }
  32. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement