diff options
author | Michael Jurka <mikejurka@google.com> | 2011-08-05 15:58:53 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-08-05 15:58:53 -0700 |
commit | 57e0ae249038ed9fda446ae45d0b916110eca50f (patch) | |
tree | e77368bfdb6b2d23943d13371151a39477efcaa6 /src/com/android/launcher2/Launcher.java | |
parent | bacd9efce7acbde09cc28b7d449887959165a7a3 (diff) | |
parent | 4554ee16f122a3dbd9a8d3b828f1c8c7e7b7fe99 (diff) | |
download | packages_apps_trebuchet-57e0ae249038ed9fda446ae45d0b916110eca50f.zip packages_apps_trebuchet-57e0ae249038ed9fda446ae45d0b916110eca50f.tar.gz packages_apps_trebuchet-57e0ae249038ed9fda446ae45d0b916110eca50f.tar.bz2 |
Merge "Small code cleanup in folders, prevent crash issue 5082899"
Diffstat (limited to 'src/com/android/launcher2/Launcher.java')
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 6d8fd4d..1af3f71 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -1460,25 +1460,6 @@ public final class Launcher extends Activity } } - public void closeFolder() { - Folder folder = mWorkspace.getOpenFolder(); - if (folder != null) { - closeFolder(folder); - } - } - - void closeFolder(Folder folder) { - folder.getInfo().opened = false; - - ViewGroup parent = (ViewGroup) folder.getParent().getParent(); - if (parent != null) { - FolderIcon fi = (FolderIcon) mWorkspace.getViewForTag(folder.mInfo); - shrinkAndFadeInFolderIcon(fi); - mDragController.removeDropTarget((DropTarget)folder); - } - folder.animateClosed(); - } - /** * Re-listen when widgets are reset. */ @@ -1724,11 +1705,34 @@ public final class Launcher extends Activity growAndFadeOutFolderIcon(folderIcon); info.opened = true; - mDragLayer.addView(folder); - mDragController.addDropTarget((DropTarget) folder); - + // Just verify that the folder hasn't already been added to the DragLayer. + // There was a one-off crash where the folder had a parent already. + if (folder.getParent() == null) { + mDragLayer.addView(folder); + mDragController.addDropTarget((DropTarget) folder); + } else { + Log.w(TAG, "Opening folder (" + folder + ") which already has a parent (" + + folder.getParent() + ")."); + } folder.animateOpen(); - folder.onOpen(); + } + + public void closeFolder() { + Folder folder = mWorkspace.getOpenFolder(); + if (folder != null) { + closeFolder(folder); + } + } + + void closeFolder(Folder folder) { + folder.getInfo().opened = false; + + ViewGroup parent = (ViewGroup) folder.getParent().getParent(); + if (parent != null) { + FolderIcon fi = (FolderIcon) mWorkspace.getViewForTag(folder.mInfo); + shrinkAndFadeInFolderIcon(fi); + } + folder.animateClosed(); } public boolean onLongClick(View v) { |