From ea889a294be004f4b1c21e9b874f9e63abfb8bd6 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Tue, 27 Mar 2012 16:45:39 -0700 Subject: Fix non-persistence of launcher (broken by reordering changes) Change-Id: I6fb9cb2257844e642df9b5599188b1cfce35df9b --- src/com/android/launcher2/CellLayout.java | 10 +++++++--- src/com/android/launcher2/Workspace.java | 16 ++-------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index 01ab8ec03..ce914e17a 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -2067,10 +2067,14 @@ public class CellLayout extends ViewGroup { } int childCount = mShortcutsAndWidgets.getChildCount(); for (int i = 0; i < childCount; i++) { - LayoutParams lp = (LayoutParams) mShortcutsAndWidgets.getChildAt(i).getLayoutParams(); - lp.cellX = lp.tmpCellX; - lp.cellY = lp.tmpCellY; + View child = mShortcutsAndWidgets.getChildAt(i); + LayoutParams lp = (LayoutParams) child.getLayoutParams(); + ItemInfo info = (ItemInfo) child.getTag(); + info.cellX = lp.cellX = lp.tmpCellX; + info.cellY = lp.cellY = lp.tmpCellY; } + Workspace workspace = (Workspace) getParent(); + workspace.updateItemLocationsInDatabase(this); } public void setUseTempCoords(boolean useTempCoords) { diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index c64782c96..2b69a1276 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -3112,7 +3112,7 @@ public class Workspace extends SmoothPagedView // when dragging and dropping, just find the closest free spot mTargetCell = mDragTargetLayout.createArea((int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], 1, 1, 1, 1, - null, mTargetCell, null, CellLayout.MODE_ON_DROP); + null, mTargetCell, null, CellLayout.MODE_ON_DROP_EXTERNAL); } else { cellLayout.findCellForSpan(mTargetCell, 1, 1); } @@ -3343,23 +3343,11 @@ public class Workspace extends SmoothPagedView mDragOutline = null; mDragInfo = null; - saveWorkspaceStateToDb(); // Hide the scrolling indicator after you pick up an item hideScrollingIndicator(false); } - public void saveWorkspaceStateToDb() { - int count = getChildCount(); - for (int i = 0; i < count; i++) { - CellLayout cl = (CellLayout) getChildAt(i); - if (cl.isItemPlacementDirty()) { - updateItemLocationsInDatabase(cl); - cl.setItemPlacementDirty(false); - } - } - } - - private void updateItemLocationsInDatabase(CellLayout cl) { + void updateItemLocationsInDatabase(CellLayout cl) { int count = cl.getShortcutsAndWidgets().getChildCount(); int screen = indexOfChild(cl); for (int i = 0; i < count; i++) { -- cgit v1.2.3