Fix bug where item was not moved in database when added to a Folder.

I thought calling arrangeChildren(saveChanges=true) would handle
this case, but because we set the position and rank in addViewForRank,
arrangeChildren does not see any changes to save.

Change-Id: Iab0fefe6da7711857ea05955a3243459f4e8527b
This commit is contained in:
Jon Miranda
2017-05-23 11:45:17 -07:00
parent db894b9bba
commit 4e54a4cfa5

View File

@@ -1437,6 +1437,9 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
@Override
public void onAdd(ShortcutInfo item, int rank) {
View view = mContent.createAndAddViewForRank(item, rank);
mLauncher.getModelWriter().addOrMoveItemInDatabase(item, mInfo.id, 0, item.cellX,
item.cellY);
ArrayList<View> items = new ArrayList<>(getItemsInReadingOrder());
items.add(rank, view);
mContent.arrangeChildren(items, items.size());