summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/Folder.java
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2012-06-14 11:41:04 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-06-14 11:41:04 -0700
commite783cde98d59a2df1d4645f07b278322cab16ecb (patch)
treeef5e1c72d77a9bb8bdf2730385275e8cedb79c8f /src/com/android/launcher2/Folder.java
parent51600e4b63a2cecd5637f0b39845c52bdcd40247 (diff)
parentfb91f303f5e672f9b4c4f9f8a03486b224d60cd6 (diff)
downloadandroid_packages_apps_Trebuchet-e783cde98d59a2df1d4645f07b278322cab16ecb.tar.gz
android_packages_apps_Trebuchet-e783cde98d59a2df1d4645f07b278322cab16ecb.tar.bz2
android_packages_apps_Trebuchet-e783cde98d59a2df1d4645f07b278322cab16ecb.zip
Merge "Adding animation when destroying folder due to single item remaining"
Diffstat (limited to 'src/com/android/launcher2/Folder.java')
-rw-r--r--src/com/android/launcher2/Folder.java59
1 files changed, 36 insertions, 23 deletions
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index b6aafe49f..dfbe8d2c3 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -108,6 +108,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.
*
@@ -941,34 +943,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