Fix a drag and drop issue: if a drop happened too quickly it could go to the wrong screen.
Change-Id: I00c73e81e754766cdc47a6286e2b969fcf10aa7c
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index c6def18..01985e9 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -27,7 +27,6 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
@@ -47,8 +46,6 @@
* A workspace is meant to be used with a fixed width only.
*/
public class Workspace extends ViewGroup implements DropTarget, DragSource, DragScroller {
- private static final String TAG = "Launcher.Workspace";
-
private static final int INVALID_SCREEN = -1;
/**
@@ -932,7 +929,8 @@
// Move internally
if (mDragInfo != null) {
final View cell = mDragInfo.cell;
- if (mCurrentScreen != mDragInfo.screen) {
+ int index = mScroller.isFinished() ? mCurrentScreen : mNextScreen;
+ if (index != mDragInfo.screen) {
final CellLayout originalCellLayout = (CellLayout) getChildAt(mDragInfo.screen);
originalCellLayout.removeView(cell);
cellLayout.addView(cell);
@@ -944,7 +942,7 @@
final ItemInfo info = (ItemInfo)cell.getTag();
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) cell.getLayoutParams();
LauncherModel.moveItemInDatabase(mLauncher, info,
- LauncherSettings.Favorites.CONTAINER_DESKTOP, mCurrentScreen, lp.cellX, lp.cellY);
+ LauncherSettings.Favorites.CONTAINER_DESKTOP, index, lp.cellX, lp.cellY);
}
}
}