Mark cells as unoccupied in onDragStart instead of startDrag.
Also move cleanup (resetting variables to null) to onDragEnd
instead of onDropCompleted. These changes are necessary because
pre-drags (for apps with shortcuts) don't call onDragStart
or onDropCompleted.
Bug: 32246571
Change-Id: Ib18fac64555e9158b776f9c12afc2cb807b3c355
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 5d3cbb2..191135d 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -2215,10 +2215,6 @@
return solution;
}
- public void prepareChildForDrag(View child) {
- markCellsAsUnoccupiedForView(child);
- }
-
/* This seems like it should be obvious and straight-forward, but when the direction vector
needs to match with the notion of the dragView pushing other views, we have to employ
a slightly more subtle notion of the direction vector. The question is what two points is
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 79a81ec..52fb527 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -410,6 +410,11 @@
enforceDragParity("onDragStart", 0, 0);
}
+ if (mDragInfo != null && mDragInfo.cell != null) {
+ CellLayout layout = (CellLayout) mDragInfo.cell.getParent().getParent();
+ layout.markCellsAsUnoccupiedForView(mDragInfo.cell);
+ }
+
if (mOutlineProvider != null) {
// The outline is used to visualize where the item will land if dropped
mOutlineProvider.generateDragOutline(mCanvas);
@@ -477,6 +482,8 @@
// Re-enable any Un/InstallShortcutReceiver and now process any queued items
InstallShortcutReceiver.disableAndFlushInstallQueue(getContext());
+ mOutlineProvider = null;
+ mDragInfo = null;
mDragSourceInternal = null;
mLauncher.onInteractionEnd();
}
@@ -2244,8 +2251,6 @@
mDragInfo = cellInfo;
child.setVisibility(INVISIBLE);
- CellLayout layout = (CellLayout) child.getParent().getParent();
- layout.prepareChildForDrag(child);
if (options.isAccessibleDrag) {
mDragController.addDragListener(new AccessibleDragListenerAdapter(
@@ -3668,8 +3673,6 @@
&& mDragInfo.cell != null) {
mDragInfo.cell.setVisibility(VISIBLE);
}
- mOutlineProvider = null;
- mDragInfo = null;
if (!isFlingToDelete) {
// Fling to delete already exits spring loaded mode after the animation finishes.