OSDN Git Service

Revised workspace fling physics
authorAdam Powell <adamp@google.com>
Tue, 13 Apr 2010 19:40:24 +0000 (12:40 -0700)
committerAdam Powell <adamp@google.com>
Tue, 13 Apr 2010 19:40:24 +0000 (12:40 -0700)
Change-Id: Ia14ff132e49390bf3bc4ac6ebf1b3eded8d39caf

src/com/android/launcher2/Workspace.java

index 7a17516..8f5bd29 100644 (file)
@@ -60,7 +60,7 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
     /**
      * The velocity at which a fling gesture will cause us to snap to the next screen
      */
-    private static final int SNAP_VELOCITY = 1000;
+    private static final int SNAP_VELOCITY = 600;
 
     private final WallpaperManager mWallpaperManager;
     
@@ -600,6 +600,11 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
             return true;
         }
 
+        if (mVelocityTracker == null) {
+            mVelocityTracker = VelocityTracker.obtain();
+        }
+        mVelocityTracker.addMovement(ev);
+        
         switch (action & MotionEvent.ACTION_MASK) {
             case MotionEvent.ACTION_MOVE: {
                 /*
@@ -682,6 +687,11 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
                 mTouchState = TOUCH_STATE_REST;
                 mActivePointerId = INVALID_POINTER;
                 mAllowLongPress = false;
+                
+                if (mVelocityTracker != null) {
+                    mVelocityTracker.recycle();
+                    mVelocityTracker = null;
+                }
 
                 break;