diff options
author | Adam Cohen <adamcohen@google.com> | 2011-08-03 16:13:21 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2011-08-03 16:18:15 -0700 |
commit | 4554ee16f122a3dbd9a8d3b828f1c8c7e7b7fe99 (patch) | |
tree | aeda4f665f33ae8e8dac5c7375101bf68487a23a /src/com/android/launcher2/Launcher.java | |
parent | aaf473c2bb6329b3b09ed2e19de6aae26077050c (diff) | |
download | packages_apps_trebuchet-4554ee16f122a3dbd9a8d3b828f1c8c7e7b7fe99.zip packages_apps_trebuchet-4554ee16f122a3dbd9a8d3b828f1c8c7e7b7fe99.tar.gz packages_apps_trebuchet-4554ee16f122a3dbd9a8d3b828f1c8c7e7b7fe99.tar.bz2 |
Small code cleanup in folders, prevent crash issue 5082899
Change-Id: Iccd4a1367f895dac7925ceae7cd7934b95e81474
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 ac85f98..b132870 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -1491,25 +1491,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. */ @@ -1755,11 +1736,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) { |