GestureListener

class MyGestureDetector extends SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) return false; // right to left swipe if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { // viewFlipper.setInAnimation(slideLeftIn); // viewFlipper.setOutAnimation(slideLeftOut); // viewFlipper.showNext(); if (playPramGetter.getSongInfoSequence().hasNext()) { songInfo = playPramGetter.getSongInfoSequence().next(); if(songInfo!=null){ songImageButton.changSongInfo(); songInfoView.changSongInfo(); } // periousArrowButton.changSongInfo(); // nextArrowButton.changSongInfo(); } } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { // viewFlipper.setInAnimation(slideRightIn); // viewFlipper.setOutAnimation(slideRightOut); // viewFlipper.showPrevious(); if (playPramGetter.getSongInfoSequence().hasPrevious()) { songInfo = playPramGetter.getSongInfoSequence() .previous(); if(songInfo!=null){ songImageButton.changSongInfo(); songInfoView.changSongInfo(); } // periousArrowButton.changSongInfo(); // nextArrowButton.changSongInfo(); } } } catch (Exception e) { // nothing } return false; } }

你可能感兴趣的:(GestureListener)