diff --git a/src/ch/blinkenlights/android/vanilla/SlidingView.java b/src/ch/blinkenlights/android/vanilla/SlidingView.java index b8d5be2b..76b801f0 100644 --- a/src/ch/blinkenlights/android/vanilla/SlidingView.java +++ b/src/ch/blinkenlights/android/vanilla/SlidingView.java @@ -40,6 +40,10 @@ public class SlidingView extends FrameLayout * Ignore drag until we made 30 px progress. */ private final float MAX_PROGRESS = 30; + /** + * Duration of the animate() call in ms + */ + private final int ANIMATION_DURATION = 250; /** * The maximum (initial) offset of the view */ @@ -53,9 +57,9 @@ public class SlidingView extends FrameLayout */ private float mProgressPx = 0; /** - * Signals the direction of the fling + * Signals the direction and speed of the fling */ - private int mFlingDirection = 0; + private float mFlingVelocity = 0; /** * TRUE if we started to move this view */ @@ -154,6 +158,7 @@ public class SlidingView extends FrameLayout this .animate() .translationY(pxOff) + .setDuration(ANIMATION_DURATION) .setListener(new AnimationListener()) .setInterpolator(new DecelerateInterpolator()); } @@ -269,15 +274,11 @@ public class SlidingView extends FrameLayout } else { int nstages = mStages.size(); int tstage = 0; - int tbonus = (int)mProgressPx * mFlingDirection; // we add the progress as virtual bonus on fling - int toff = Integer.MAX_VALUE; - - for (int i=0; i 0 ? 1 : -1); + mFlingVelocity = velocityY; return true; } }