Fixing issue where drag view is jumping when you scroll from hovering over an edge.  (Bug 8522679)

Change-Id: Ie523e718bd1b558db9608aa66f6c353e4b8e1a14
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index 3e586bf..1d6472f 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -488,6 +488,23 @@
         DropTarget dropTarget = findDropTarget(x, y, coordinates);
         mDragObject.x = coordinates[0];
         mDragObject.y = coordinates[1];
+        checkTouchMove(dropTarget);
+
+        // Check if we are hovering over the scroll areas
+        mDistanceSinceScroll +=
+            Math.sqrt(Math.pow(mLastTouch[0] - x, 2) + Math.pow(mLastTouch[1] - y, 2));
+        mLastTouch[0] = x;
+        mLastTouch[1] = y;
+        checkScrollState(x, y);
+    }
+
+    public void forceTouchMove() {
+        int[] dummyCoordinates = mCoordinatesTemp;
+        DropTarget dropTarget = findDropTarget(mLastTouch[0], mLastTouch[1], dummyCoordinates);
+        checkTouchMove(dropTarget);
+    }
+
+    private void checkTouchMove(DropTarget dropTarget) {
         if (dropTarget != null) {
             DropTarget delegate = dropTarget.getDropTargetDelegate(mDragObject);
             if (delegate != null) {
@@ -507,14 +524,10 @@
             }
         }
         mLastDropTarget = dropTarget;
+    }
 
-        // After a scroll, the touch point will still be in the scroll region.
-        // Rather than scrolling immediately, require a bit of twiddling to scroll again
+    private void checkScrollState(int x, int y) {
         final int slop = ViewConfiguration.get(mLauncher).getScaledWindowTouchSlop();
-        mDistanceSinceScroll +=
-            Math.sqrt(Math.pow(mLastTouch[0] - x, 2) + Math.pow(mLastTouch[1] - y, 2));
-        mLastTouch[0] = x;
-        mLastTouch[1] = y;
         final int delay = mDistanceSinceScroll < slop ? RESCROLL_DELAY : SCROLL_DELAY;
 
         if (x < mScrollZone) {
@@ -540,12 +553,6 @@
         }
     }
 
-    public void forceMoveEvent() {
-        if (mDragging) {
-            handleMoveEvent(mDragObject.x, mDragObject.y);
-        }
-    }
-
     /**
      * Call this from a drag source view.
      */
@@ -796,8 +803,8 @@
                 mLauncher.getDragLayer().onExitScrollArea();
 
                 if (isDragging()) {
-                    // Force an update so that we can requeue the scroller if necessary
-                    forceMoveEvent();
+                    // Check the scroll again so that we can requeue the scroller if necessary
+                    checkScrollState(mLastTouch[0], mLastTouch[1]);
                 }
             }
         }