Refactor of Launcher drag and drop to use a DragObject

-> DragObject contains a bunch of parameters instead of pssing
   them each individually

Change-Id: I709cf320fe4234d71e19325d5c761dd9a9bba405
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index d308209..ead2c5d 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -17,6 +17,7 @@
 package com.android.launcher2;
 
 import com.android.launcher.R;
+import com.android.launcher2.DropTarget.DragObject;
 
 import android.content.ComponentName;
 import android.content.Context;
@@ -671,28 +672,16 @@
      * We don't actually use AllAppsPagedView as a drop target... it's only used to intercept a drop
      * to the workspace.
      */
-    @Override
-    public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public boolean acceptDrop(DragObject d) {
         return false;
     }
-    @Override
-    public DropTarget getDropTargetDelegate(DragSource source, int x, int y, int xOffset,
-            int yOffset, DragView dragView, Object dragInfo) {
+    public DropTarget getDropTargetDelegate(DragObject d) {
         return null;
     }
-    @Override
-    public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {}
-    @Override
-    public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {}
-    @Override
-    public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {}
-    @Override
-    public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {}
+    public void onDragEnter(DragObject d) {}
+    public void onDragExit(DragObject d) {}
+    public void onDragOver(DragObject d) {}
+    public void onDrop(DragObject d) {}
 
     public boolean isDropEnabled() {
         return true;
diff --git a/src/com/android/launcher2/ApplicationInfoDropTarget.java b/src/com/android/launcher2/ApplicationInfoDropTarget.java
index f42aaf5..e02878a 100644
--- a/src/com/android/launcher2/ApplicationInfoDropTarget.java
+++ b/src/com/android/launcher2/ApplicationInfoDropTarget.java
@@ -17,6 +17,7 @@
 package com.android.launcher2;
 
 import com.android.launcher.R;
+import com.android.launcher2.DropTarget.DragObject;
 
 import android.animation.Animator;
 import android.animation.AnimatorSet;
@@ -61,33 +62,30 @@
         }
     }
 
-    public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public boolean acceptDrop(DragObject d) {
         // acceptDrop is called just before onDrop. We do the work here, rather than
         // in onDrop, because it allows us to reject the drop (by returning false)
         // so that the object being dragged isn't removed from the home screen.
         if (getVisibility() != VISIBLE) return false;
 
         ComponentName componentName = null;
-        if (dragInfo instanceof ApplicationInfo) {
-            componentName = ((ApplicationInfo)dragInfo).componentName;
-        } else if (dragInfo instanceof ShortcutInfo) {
-            componentName = ((ShortcutInfo)dragInfo).intent.getComponent();
+        if (d.dragInfo instanceof ApplicationInfo) {
+            componentName = ((ApplicationInfo) d.dragInfo).componentName;
+        } else if (d.dragInfo instanceof ShortcutInfo) {
+            componentName = ((ShortcutInfo) d.dragInfo).intent.getComponent();
         }
         mLauncher.startApplicationDetailsActivity(componentName);
         return false;
     }
 
-    public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDragEnter(DragObject d) {
         if (!mDragAndDropEnabled) return;
-        dragView.setPaint(mHoverPaint);
+        d.dragView.setPaint(mHoverPaint);
     }
 
-    public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDragExit(DragObject d) {
         if (!mDragAndDropEnabled) return;
-        dragView.setPaint(null);
+        d.dragView.setPaint(null);
     }
 
     public void onDragStart(DragSource source, Object info, int dragAction) {
diff --git a/src/com/android/launcher2/DeleteZone.java b/src/com/android/launcher2/DeleteZone.java
index 5d9b5db..21b1cf1 100644
--- a/src/com/android/launcher2/DeleteZone.java
+++ b/src/com/android/launcher2/DeleteZone.java
@@ -33,6 +33,7 @@
 import android.view.animation.AccelerateInterpolator;
 
 import com.android.launcher.R;
+import com.android.launcher2.DropTarget.DragObject;
 
 public class DeleteZone extends IconDropTarget {
     private static final int ORIENTATION_HORIZONTAL = 1;
@@ -90,16 +91,14 @@
         mDragTextColor = r.getColor(R.color.workspace_delete_zone_drag_text_color);
     }
 
-    public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public boolean acceptDrop(DragObject d) {
         return true;
     }
 
-    public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDrop(DragObject d) {
         if (!mDragAndDropEnabled) return;
 
-        final ItemInfo item = (ItemInfo) dragInfo;
+        final ItemInfo item = (ItemInfo) d.dragInfo;
 
         // On x-large screens, you can uninstall an app by dragging from all apps
         if (item instanceof ApplicationInfo && LauncherApplication.isScreenLarge()) {
@@ -135,21 +134,19 @@
         LauncherModel.deleteItemFromDatabase(mLauncher, item);
     }
 
-    public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDragEnter(DragObject d) {
         if (mDragAndDropEnabled) {
             mTransition.reverseTransition(getTransitionAnimationDuration());
             setTextColor(mDragTextColor);
-            super.onDragEnter(source, x, y, xOffset, yOffset, dragView, dragInfo);
+            super.onDragEnter(d);
         }
     }
 
-    public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDragExit(DragObject d) {
         if (mDragAndDropEnabled) {
             mTransition.reverseTransition(getTransitionAnimationDuration());
             setTextColor(mTextColor);
-            super.onDragExit(source, x, y, xOffset, yOffset, dragView, dragInfo);
+            super.onDragExit(d);
         }
     }
 
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index 5ca1e1c..1690cac 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -35,6 +35,7 @@
 import android.view.inputmethod.InputMethodManager;
 
 import com.android.launcher.R;
+import com.android.launcher2.DropTarget.DragObject;
 
 /**
  * Class for initiating a drag within a view or across multiple views.
@@ -84,25 +85,12 @@
     /** Original view that is being dragged.  */
     private View mOriginator;
 
-    /** X offset from the upper-left corner of the cell to where we touched.  */
-    private int mTouchOffsetX;
-
-    /** Y offset from the upper-left corner of the cell to where we touched.  */
-    private int mTouchOffsetY;
-
     /** the area at the edge of the screen that makes the workspace go left
      *   or right while you're dragging.
      */
     private int mScrollZone;
 
-    /** Where the drag originated */
-    private DragSource mDragSource;
-
-    /** The data associated with the object being dragged */
-    private Object mDragInfo;
-
-    /** The view that moves around while you drag.  */
-    private DragView mDragView;
+    private DropTarget.DragObject mDragObject = new DropTarget.DragObject();
 
     /** Who can receive drop events */
     private ArrayList<DropTarget> mDropTargets = new ArrayList<DropTarget>();
@@ -295,17 +283,17 @@
         final int dragRegionLeft = dragRegion == null ? 0 : dragRegion.left;
         final int dragRegionTop = dragRegion == null ? 0 : dragRegion.top;
 
-        mTouchOffsetX = mMotionDownX - (screenX + dragRegionLeft);
-        mTouchOffsetY = mMotionDownY - (screenY + dragRegionTop);
-
         mDragging = true;
-        mDragSource = source;
-        mDragInfo = dragInfo;
+
+        mDragObject.xOffset = mMotionDownX - (screenX + dragRegionLeft);
+        mDragObject.yOffset = mMotionDownY - (screenY + dragRegionTop);
+        mDragObject.dragSource = source;
+        mDragObject.dragInfo = dragInfo;
 
         mVibrator.vibrate(VIBRATE_DURATION);
 
-        DragView dragView = mDragView = new DragView(mContext, b, registrationX, registrationY,
-                0, 0, b.getWidth(), b.getHeight());
+        final DragView dragView = mDragObject.dragView = new DragView(mContext, b, registrationX,
+                registrationY, 0, 0, b.getWidth(), b.getHeight());
 
         final DragSource dragSource = source;
         dragView.setOnDrawRunnable(new Runnable() {
@@ -386,7 +374,7 @@
     public void cancelDrag() {
         if (mDragging) {
             // Should we also be calling onDragExit() here?
-            mDragSource.onDropCompleted(null, mDragInfo, false);
+            mDragObject.dragSource.onDropCompleted(null, mDragObject.dragInfo, false);
         }
         endDrag();
     }
@@ -400,9 +388,9 @@
             for (DragListener listener : mListeners) {
                 listener.onDragEnd();
             }
-            if (mDragView != null) {
-                mDragView.remove();
-                mDragView = null;
+            if (mDragObject.dragView != null) {
+                mDragObject.dragView.remove();
+                mDragObject.dragView = null;
             }
         }
     }
@@ -459,33 +447,29 @@
     }
 
     private void handleMoveEvent(int x, int y) {
-        mDragView.move(x, y);
+        mDragObject.dragView.move(x, y);
 
         // Drop on someone?
         final int[] coordinates = mCoordinatesTemp;
         DropTarget dropTarget = findDropTarget(x, y, coordinates);
+        mDragObject.x = coordinates[0];
+        mDragObject.y = coordinates[1];
         if (dropTarget != null) {
-            DropTarget delegate = dropTarget.getDropTargetDelegate(
-                    mDragSource, coordinates[0], coordinates[1],
-                    (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
+            DropTarget delegate = dropTarget.getDropTargetDelegate(mDragObject);
             if (delegate != null) {
                 dropTarget = delegate;
             }
 
             if (mLastDropTarget != dropTarget) {
                 if (mLastDropTarget != null) {
-                    mLastDropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
-                        (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
+                    mLastDropTarget.onDragExit(mDragObject);
                 }
-                dropTarget.onDragEnter(mDragSource, coordinates[0], coordinates[1],
-                    (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
+                dropTarget.onDragEnter(mDragObject);
             }
-            dropTarget.onDragOver(mDragSource, coordinates[0], coordinates[1],
-                    (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
+            dropTarget.onDragOver(mDragObject);
         } else {
             if (mLastDropTarget != null) {
-                mLastDropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
-                    (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
+                mLastDropTarget.onDragExit(mDragObject);
             }
         }
         mLastDropTarget = dropTarget;
@@ -578,18 +562,18 @@
         final int[] coordinates = mCoordinatesTemp;
         final DropTarget dropTarget = findDropTarget((int) x, (int) y, coordinates);
 
+        mDragObject.x = coordinates[0];
+        mDragObject.y = coordinates[1];
         boolean accepted = false;
         if (dropTarget != null) {
-            dropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
-                    (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
-            if (dropTarget.acceptDrop(mDragSource, coordinates[0], coordinates[1],
-                    (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo)) {
-                dropTarget.onDrop(mDragSource, coordinates[0], coordinates[1],
-                        (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
+            dropTarget.onDragExit(mDragObject);
+            if (dropTarget.acceptDrop(mDragObject)) {
+                dropTarget.onDrop(mDragObject);
                 accepted = true;
             }
         }
-        mDragSource.onDropCompleted((View) dropTarget, mDragInfo, accepted);
+        mDragObject.dragSource.onDropCompleted((View) dropTarget, mDragObject.dragInfo, accepted);
+
     }
 
     private DropTarget findDropTarget(int x, int y, int[] dropCoordinates) {
@@ -608,9 +592,10 @@
             target.getLocationOnScreen(dropCoordinates);
             r.offset(dropCoordinates[0] - target.getLeft(), dropCoordinates[1] - target.getTop());
 
+            mDragObject.x = x;
+            mDragObject.y = y;
             if (r.contains(x, y)) {
-                DropTarget delegate = target.getDropTargetDelegate(mDragSource,
-                        x, y, (int)mTouchOffsetX, (int)mTouchOffsetY, mDragView, mDragInfo);
+                DropTarget delegate = target.getDropTargetDelegate(mDragObject);
                 if (delegate != null) {
                     target = delegate;
                     target.getLocationOnScreen(dropCoordinates);
@@ -701,7 +686,7 @@
     }
 
     DragView getDragView() {
-        return mDragView;
+        return mDragObject.dragView;
     }
 
     private class ScrollRunnable implements Runnable {
diff --git a/src/com/android/launcher2/DropTarget.java b/src/com/android/launcher2/DropTarget.java
index 308dbbe..9c0faf3 100644
--- a/src/com/android/launcher2/DropTarget.java
+++ b/src/com/android/launcher2/DropTarget.java
@@ -23,6 +23,30 @@
  *
  */
 public interface DropTarget {
+
+    class DragObject {
+        public int x = -1;
+        public int y = -1;
+
+        /** X offset from the upper-left corner of the cell to where we touched.  */
+        public int xOffset = -1;
+
+        /** Y offset from the upper-left corner of the cell to where we touched.  */
+        public int yOffset = -1;
+
+        /** The view that moves around while you drag.  */
+        public DragView dragView = null;
+
+        /** The data associated with the object being dragged */
+        public Object dragInfo = null;
+
+        /** Where the drag originated */
+        public DragSource dragSource = null;
+
+        public DragObject() {
+        }
+    }
+
     /**
      * Used to temporarily disable certain drop targets
      *
@@ -44,17 +68,13 @@
      * @param dragInfo Data associated with the object being dragged
      * 
      */
-    void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo);
-    
-    void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo);
+    void onDrop(DragObject dragObject);
 
-    void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo);
+    void onDragEnter(DragObject dragObject);
 
-    void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo);
+    void onDragOver(DragObject dragObject);
+
+    void onDragExit(DragObject dragObject);
 
     /**
      * Allows a DropTarget to delegate drag and drop events to another object.
@@ -73,8 +93,7 @@
      *
      * @return The DropTarget to delegate to, or null to not delegate to another object.
      */
-    DropTarget getDropTargetDelegate(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo);
+    DropTarget getDropTargetDelegate(DragObject dragObject);
 
     /**
      * Check if a drop action can occur at, or near, the requested location.
@@ -91,8 +110,7 @@
      * @param dragInfo Data associated with the object being dragged
      * @return True if the drop will be accepted, false otherwise.
      */
-    boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo);
+    boolean acceptDrop(DragObject dragObject);
 
     // These methods are implemented in Views
     void getHitRect(Rect outRect);
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index 0470e41..76e9b35 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -363,25 +363,23 @@
         bind(mInfo);
     }
 
-    public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
-        final ItemInfo item = (ItemInfo) dragInfo;
+    public boolean acceptDrop(DragObject d) {
+        final ItemInfo item = (ItemInfo) d.dragInfo;
         final int itemType = item.itemType;
         return ((itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION ||
                     itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) &&
                     !isFull());
     }
 
-    public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDrop(DragObject d) {
         ShortcutInfo item;
-        if (dragInfo instanceof ApplicationInfo) {
+        if (d.dragInfo instanceof ApplicationInfo) {
             // Came from all apps -- make a copy
-            item = ((ApplicationInfo)dragInfo).makeShortcut();
+            item = ((ApplicationInfo) d.dragInfo).makeShortcut();
             item.spanX = 1;
             item.spanY = 1;
         } else {
-            item = (ShortcutInfo)dragInfo;
+            item = (ShortcutInfo) d.dragInfo;
         }
         mInfo.add(item);
         LauncherModel.addOrMoveItemInDatabase(mLauncher, item, mInfo.id, 0, item.cellX, item.cellY);
@@ -417,19 +415,16 @@
         mContent.addViewToCellLayout(textView, insert ? 0 : -1, (int)item.id, lp, true);
     }
 
-    public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDragEnter(DragObject d) {
         mContent.onDragEnter();
     }
 
-    public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
-        float[] r = mapPointFromScreenToContent(x, y, null);
+    public void onDragOver(DragObject d) {
+        float[] r = mapPointFromScreenToContent(d.x, d.y, null);
         mContent.visualizeDropLocation(null, null, (int) r[0], (int) r[1], 1, 1);
     }
 
-    public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDragExit(DragObject d) {
         mContent.onDragExit();
     }
 
@@ -453,8 +448,7 @@
         return true;
     }
 
-    public DropTarget getDropTargetDelegate(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public DropTarget getDropTargetDelegate(DragObject d) {
         return null;
     }
 
diff --git a/src/com/android/launcher2/FolderIcon.java b/src/com/android/launcher2/FolderIcon.java
index 2a5a5a0..0091a28 100644
--- a/src/com/android/launcher2/FolderIcon.java
+++ b/src/com/android/launcher2/FolderIcon.java
@@ -58,8 +58,6 @@
 
     private int mOriginalWidth = -1;
     private int mOriginalHeight = -1;
-    private int mOriginalX = -1;
-    private int mOriginalY = -1;
 
     private int mFolderLocX;
     private int mFolderLocY;
@@ -121,9 +119,8 @@
                 !mFolder.isFull() && item != mInfo);
     }
 
-    public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
-        final ItemInfo item = (ItemInfo) dragInfo;
+    public boolean acceptDrop(DragObject d) {
+        final ItemInfo item = (ItemInfo) d.dragInfo;
         return willAcceptItem(item);
     }
 
@@ -132,14 +129,13 @@
         LauncherModel.addOrMoveItemInDatabase(mLauncher, item, mInfo.id, 0, item.cellX, item.cellY);
     }
 
-    public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDrop(DragObject d) {
         ShortcutInfo item;
-        if (dragInfo instanceof ApplicationInfo) {
+        if (d.dragInfo instanceof ApplicationInfo) {
             // Came from all apps -- make a copy
-            item = ((ApplicationInfo)dragInfo).makeShortcut();
+            item = ((ApplicationInfo) d.dragInfo).makeShortcut();
         } else {
-            item = (ShortcutInfo)dragInfo;
+            item = (ShortcutInfo) d.dragInfo;
         }
         item.cellX = -1;
         item.cellY = -1;
@@ -149,8 +145,6 @@
     void saveState(CellLayout.LayoutParams lp) {
         mOriginalWidth = lp.width;
         mOriginalHeight = lp.height;
-        mOriginalX = lp.x;
-        mOriginalY = lp.y;
     }
 
     private void animateToAcceptState() {
@@ -213,27 +207,22 @@
         mFolderLocY = tvLocation[1] - wsLocation[1] + getMeasuredHeight() / 2;
     }
 
-    public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
-        if (!willAcceptItem((ItemInfo) dragInfo)) return;
+    public void onDragEnter(DragObject d) {
+        if (!willAcceptItem((ItemInfo) d.dragInfo)) return;
         determineFolderLocationInWorkspace();
         mLauncher.getWorkspace().showFolderAccept(this);
         animateToAcceptState();
     }
 
-    public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDragOver(DragObject d) {
     }
 
-    public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
-        if (!willAcceptItem((ItemInfo) dragInfo)) return;
+    public void onDragExit(DragObject d) {
+        if (!willAcceptItem((ItemInfo) d.dragInfo)) return;
         animateToNaturalState();
     }
 
-    @Override
-    public DropTarget getDropTargetDelegate(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public DropTarget getDropTargetDelegate(DragObject d) {
         return null;
     }
 
diff --git a/src/com/android/launcher2/IconDropTarget.java b/src/com/android/launcher2/IconDropTarget.java
index 4d018e6..a091f6c 100644
--- a/src/com/android/launcher2/IconDropTarget.java
+++ b/src/com/android/launcher2/IconDropTarget.java
@@ -82,32 +82,27 @@
         mDragAndDropEnabled = enabled;
     }
 
-    public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public boolean acceptDrop(DragObject d) {
         return false;
     }
 
-    public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDrop(DragObject d) {
         // Do nothing
     }
 
-    public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDragEnter(DragObject d) {
         if (mDragAndDropEnabled) {
-            dragView.setPaint(mHoverPaint);
+            d.dragView.setPaint(mHoverPaint);
         }
     }
 
-    public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDragOver(DragObject d) {
         // Do nothing
     }
 
-    public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDragExit(DragObject d) {
         if (mDragAndDropEnabled) {
-            dragView.setPaint(null);
+            d.dragView.setPaint(null);
         }
     }
 
@@ -135,8 +130,7 @@
     }
 
     @Override
-    public DropTarget getDropTargetDelegate(DragSource source, int x, int y, int xOffset,
-            int yOffset, DragView dragView, Object dragInfo) {
+    public DropTarget getDropTargetDelegate(DragObject d) {
         return null;
     }
 }
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 3f0c54e..7d2626d 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -2379,11 +2379,10 @@
     /**
      * {@inheritDoc}
      */
-    public boolean acceptDrop(DragSource source, int x, int y,
-            int xOffset, int yOffset, DragView dragView, Object dragInfo) {
+    public boolean acceptDrop(DragObject d) {
 
         // If it's an external drop (e.g. from All Apps), check if it should be accepted
-        if (source != this) {
+        if (d.dragSource != this) {
             // Don't accept the drop if we're not over a screen at time of drop
             if (mDragTargetLayout == null || !mDragTargetLayout.getAcceptsDrops()) {
                 return false;
@@ -2469,10 +2468,9 @@
         return false;
     }
 
-    public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDrop(DragObject d) {
 
-        mDragViewVisualCenter = getDragViewVisualCenter(x, y, xOffset, yOffset, dragView,
+        mDragViewVisualCenter = getDragViewVisualCenter(d.x, d.y, d.xOffset, d.yOffset, d.dragView,
                 mDragViewVisualCenter);
 
         // We want the point to be mapped to the dragTarget.
@@ -2489,17 +2487,17 @@
             }
         }
 
-        if (source != this) {
+        if (d.dragSource != this) {
             final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0],
                     (int) mDragViewVisualCenter[1] };
             if (LauncherApplication.isScreenLarge() && (mIsSmall || mIsInUnshrinkAnimation)
                     && !mLauncher.isAllAppsVisible()) {
                 // When the workspace is shrunk and the drop comes from customize, don't actually
                 // add the item to the screen -- customize will do this itself
-                ((ItemInfo) dragInfo).dropPos = touchXY;
+                ((ItemInfo) d.dragInfo).dropPos = touchXY;
                 return;
             }
-            onDropExternal(touchXY, dragInfo, mDragTargetLayout, false, dragView);
+            onDropExternal(touchXY, d.dragInfo, mDragTargetLayout, false, d.dragView);
         } else if (mDragInfo != null) {
             final View cell = mDragInfo.cell;
             CellLayout dropTargetLayout = mDragTargetLayout;
@@ -2592,11 +2590,11 @@
             final CellLayout parent = (CellLayout) cell.getParent().getParent();
 
             int loc[] = new int[2];
-            getViewLocationRelativeToSelf(dragView, loc);
+            getViewLocationRelativeToSelf(d.dragView, loc);
 
             // Prepare it to be animated into its new position
             // This must be called after the view has been re-parented
-            setPositionForDropAnimation(dragView, loc[0], loc[1], parent, cell);
+            setPositionForDropAnimation(d.dragView, loc[0], loc[1], parent, cell);
             boolean animateDrop = !mWasSpringLoadedOnDragExit;
             parent.onDropChild(cell, animateDrop);
         }
@@ -2615,8 +2613,7 @@
         location[1] = vY - y;
     }
 
-    public void onDragEnter(DragSource source, int x, int y, int xOffset,
-            int yOffset, DragView dragView, Object dragInfo) {
+    public void onDragEnter(DragObject d) {
         mDragTargetLayout = null; // Reset the drag state
 
         if (!mIsSmall) {
@@ -2626,8 +2623,7 @@
         }
     }
 
-    public DropTarget getDropTargetDelegate(DragSource source, int x, int y,
-            int xOffset, int yOffset, DragView dragView, Object dragInfo) {
+    public DropTarget getDropTargetDelegate(DragObject d) {
 
         if (mIsSmall || mIsInUnshrinkAnimation) {
             // If we're shrunken, don't let anyone drag on folders/etc that are on the mini-screens
@@ -2637,18 +2633,18 @@
         // would land in a cell occupied by a DragTarget (e.g. a Folder),
         // then drag events should be handled by that child.
 
-        ItemInfo item = (ItemInfo) dragInfo;
+        ItemInfo item = (ItemInfo) d.dragInfo;
         CellLayout currentLayout = getCurrentDropLayout();
 
         int dragPointX, dragPointY;
         if (item.spanX == 1 && item.spanY == 1) {
             // For a 1x1, calculate the drop cell exactly as in onDragOver
-            dragPointX = x - xOffset;
-            dragPointY = y - yOffset;
+            dragPointX = d.x - d.xOffset;
+            dragPointY = d.y - d.yOffset;
         } else {
             // Otherwise, use the exact drag coordinates
-            dragPointX = x;
-            dragPointY = y;
+            dragPointX = d.x;
+            dragPointY = d.y;
         }
         dragPointX += mScrollX - currentLayout.getLeft();
         dragPointY += mScrollY - currentLayout.getTop();
@@ -2660,7 +2656,7 @@
         View child = currentLayout.getChildAt(cellXY[0], cellXY[1]);
         if (child instanceof DropTarget) {
             DropTarget target = (DropTarget)child;
-            if (target.acceptDrop(source, x, y, xOffset, yOffset, dragView, dragInfo)) {
+            if (target.acceptDrop(d)) {
                 return target;
             }
         }
@@ -2977,25 +2973,24 @@
         return res;
     }
 
-    public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo) {
+    public void onDragOver(DragObject d) {
         // When touch is inside the scroll area, skip dragOver actions for the current screen
         if (!mInScrollArea) {
             CellLayout layout;
-            int left = x - xOffset;
-            int top = y - yOffset;
+            int left = d.x - d.xOffset;
+            int top = d.y - d.yOffset;
 
-            mDragViewVisualCenter = getDragViewVisualCenter(x, y, xOffset, yOffset, dragView,
-                    mDragViewVisualCenter);
+            mDragViewVisualCenter = getDragViewVisualCenter(d.x, d.y, d.xOffset, d.yOffset,
+                    d.dragView, mDragViewVisualCenter);
 
             boolean shrunken = mIsSmall || mIsInUnshrinkAnimation;
             if (shrunken) {
-                mLastDragView = dragView;
+                mLastDragView = d.dragView;
                 mLastDragOriginX = left;
                 mLastDragOriginY = top;
-                mLastDragXOffset = xOffset;
-                mLastDragYOffset = yOffset;
-                layout = findMatchingPageForDragOver(dragView, left, top, xOffset, yOffset);
+                mLastDragXOffset = d.xOffset;
+                mLastDragYOffset = d.yOffset;
+                layout = findMatchingPageForDragOver(d.dragView, left, top, d.xOffset, d.yOffset);
 
                 if (layout != null && layout != mDragTargetLayout) {
                     if (mDragTargetLayout != null) {
@@ -3033,9 +3028,9 @@
             if (!shrunken || mShrinkState == ShrinkState.SPRING_LOADED) {
                 layout = getCurrentDropLayout();
 
-                final ItemInfo item = (ItemInfo)dragInfo;
-                if (dragInfo instanceof LauncherAppWidgetInfo) {
-                    LauncherAppWidgetInfo widgetInfo = (LauncherAppWidgetInfo)dragInfo;
+                final ItemInfo item = (ItemInfo) d.dragInfo;
+                if (d.dragInfo instanceof LauncherAppWidgetInfo) {
+                    LauncherAppWidgetInfo widgetInfo = (LauncherAppWidgetInfo) d.dragInfo;
 
                     if (widgetInfo.spanX == -1) {
                         // Calculate the grid spans needed to fit this widget
@@ -3050,7 +3045,7 @@
                     final View child = (mDragInfo == null) ? null : mDragInfo.cell;
                     // We want the point to be mapped to the dragTarget.
                     mapPointFromSelfToChild(mDragTargetLayout, mDragViewVisualCenter, null);
-                    ItemInfo info = (ItemInfo) dragInfo;
+                    ItemInfo info = (ItemInfo) d.dragInfo;
 
                     if (!willCreateUserFolder(info, mDragTargetLayout,
                             (int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1])) {
@@ -3082,8 +3077,7 @@
         clearAllHovers();
     }
 
-    public void onDragExit(DragSource source, int x, int y, int xOffset,
-            int yOffset, DragView dragView, Object dragInfo) {
+    public void onDragExit(DragObject d) {
         doDragExit();
     }