OSDN Git Service

Cap launcher swipe animations to max duration
authorChet Haase <chet@google.com>
Thu, 25 Oct 2012 23:01:11 +0000 (16:01 -0700)
committerThe Android Automerger <android-build@android.com>
Fri, 26 Oct 2012 04:43:05 +0000 (21:43 -0700)
large screens take too long swiping between screens. Cap the duration to
some max value to make things snappier.

Change-Id: Iee967c1b00b4962a0490fd0e20d48d7d8363dd2f

src/com/android/launcher2/PagedView.java

index 9b97384..2fc788b 100644 (file)
@@ -59,6 +59,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
     private static final int MIN_LENGTH_FOR_FLING = 25;
 
     protected static final int PAGE_SNAP_ANIMATION_DURATION = 550;
+    protected static final int MAX_PAGE_SNAP_DURATION = 750;
     protected static final int SLOW_PAGE_SNAP_ANIMATION_DURATION = 950;
     protected static final float NANOTIME_DIV = 1000000000.0f;
 
@@ -1473,6 +1474,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
         // user flings, so we scale the duration by a value near to the derivative of the scroll
         // interpolator at zero, ie. 5. We use 4 to make it a little slower.
         duration = 4 * Math.round(1000 * Math.abs(distance / velocity));
+        duration = Math.min(duration, MAX_PAGE_SNAP_DURATION);
 
         snapToPage(whichPage, delta, duration);
     }