diff options
author | Adam Cohen <adamcohen@google.com> | 2012-06-11 15:45:18 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2012-06-11 18:44:17 -0700 |
commit | fb91f303f5e672f9b4c4f9f8a03486b224d60cd6 (patch) | |
tree | 7581596ccc712ee3ffe8a1c77e7031d5fa546101 /src/com/android/launcher2/Folder.java | |
parent | 3abc8ed439798b7bb792b04c2d3c7f80353595a3 (diff) | |
download | android_packages_apps_Trebuchet-fb91f303f5e672f9b4c4f9f8a03486b224d60cd6.tar.gz android_packages_apps_Trebuchet-fb91f303f5e672f9b4c4f9f8a03486b224d60cd6.tar.bz2 android_packages_apps_Trebuchet-fb91f303f5e672f9b4c4f9f8a03486b224d60cd6.zip |
Adding animation when destroying folder due to single item remaining
Change-Id: I079af9a50d7d6f63092b725ecd941ab1e298032d
Diffstat (limited to 'src/com/android/launcher2/Folder.java')
-rw-r--r-- | src/com/android/launcher2/Folder.java | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java index 1163f9ec4..4669918ff 100644 --- a/src/com/android/launcher2/Folder.java +++ b/src/com/android/launcher2/Folder.java @@ -110,6 +110,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private static String sHintText; private ObjectAnimator mOpenCloseAnimator; + private boolean mDestroyed; + /** * Used to inflate the Workspace from XML. * @@ -943,34 +945,45 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } private void replaceFolderWithFinalItem() { - ItemInfo finalItem = null; + // Add the last remaining child to the workspace in place of the folder + Runnable onCompleteRunnable = new Runnable() { + @Override + public void run() { + CellLayout cellLayout = mLauncher.getCellLayout(mInfo.container, mInfo.screen); + + if (getItemCount() <= 1) { + // Remove the folder + LauncherModel.deleteItemFromDatabase(mLauncher, mInfo); + cellLayout.removeView(mFolderIcon); + if (mFolderIcon instanceof DropTarget) { + mDragController.removeDropTarget((DropTarget) mFolderIcon); + } + mLauncher.removeFolder(mInfo); + } - if (getItemCount() == 1) { - finalItem = mInfo.contents.get(0); - } + // Move the item from the folder to the workspace, in the position of the folder + if (getItemCount() == 1) { + ShortcutInfo finalItem = mInfo.contents.get(0); - // Remove the folder completely - CellLayout cellLayout = mLauncher.getCellLayout(mInfo.container, mInfo.screen); - cellLayout.removeView(mFolderIcon); - if (mFolderIcon instanceof DropTarget) { - mDragController.removeDropTarget((DropTarget) mFolderIcon); - } - mLauncher.removeFolder(mInfo); + final View child = mLauncher.createShortcut(R.layout.application, cellLayout, + finalItem); + LauncherModel.addOrMoveItemInDatabase(mLauncher, finalItem, mInfo.container, + mInfo.screen, mInfo.cellX, mInfo.cellY); + mLauncher.getWorkspace().addInScreen(child, mInfo.container, mInfo.screen, + mInfo.cellX, mInfo.cellY, mInfo.spanX, mInfo.spanY); + } - if (finalItem != null) { - LauncherModel.addOrMoveItemInDatabase(mLauncher, finalItem, mInfo.container, - mInfo.screen, mInfo.cellX, mInfo.cellY); + } + }; + View finalChild = getItemAt(0); + if (finalChild != null) { + mFolderIcon.performDestroyAnimation(finalChild, onCompleteRunnable); } - LauncherModel.deleteItemFromDatabase(mLauncher, mInfo); - - // Add the last remaining child to the workspace in place of the folder - if (finalItem != null) { - View child = mLauncher.createShortcut(R.layout.application, cellLayout, - (ShortcutInfo) finalItem); + mDestroyed = true; + } - mLauncher.getWorkspace().addInScreen(child, mInfo.container, mInfo.screen, mInfo.cellX, - mInfo.cellY, mInfo.spanX, mInfo.spanY); - } + boolean isDestroyed() { + return mDestroyed; } // This method keeps track of the last item in the folder for the purposes |