diff options
author | Winson Chung <winsonc@google.com> | 2013-12-09 16:57:45 -0800 |
---|---|---|
committer | Danesh M <daneshm90@gmail.com> | 2014-06-06 22:54:21 -0700 |
commit | 422308e7ef7897364cdd6e3973fe2574d86c9851 (patch) | |
tree | 5bb799bf2bde07e9a7940bff8329dd19158ed1b0 /src | |
parent | 33832e262378ca9e6da33f43efd406ba692bb530 (diff) | |
download | android_packages_apps_Trebuchet-422308e7ef7897364cdd6e3973fe2574d86c9851.tar.gz android_packages_apps_Trebuchet-422308e7ef7897364cdd6e3973fe2574d86c9851.tar.bz2 android_packages_apps_Trebuchet-422308e7ef7897364cdd6e3973fe2574d86c9851.zip |
Fixing crash in empty folders. (Bug 11627191)
Change-Id: I7a0e23e16a7546a9612d3406257e15be758d4c52
Signed-off-by: Winson Chung <winsonc@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/Folder.java | 15 | ||||
-rw-r--r-- | src/com/android/launcher3/FolderInfo.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherModel.java | 5 |
3 files changed, 18 insertions, 6 deletions
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index 5b696bd8b..46a60cf62 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -416,6 +416,15 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mFolderName.setText(""); } updateItemLocationsInDatabase(); + + // In case any children didn't come across during loading, clean up the folder accordingly + mFolderIcon.post(new Runnable() { + public void run() { + if (getItemCount() <= 1) { + replaceFolderWithFinalItem(); + } + } + }); } /** @@ -835,7 +844,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList View v = list.get(i); ItemInfo info = (ItemInfo) v.getTag(); LauncherModel.moveItemInDatabase(mLauncher, info, mInfo.id, 0, - info.cellX, info.cellY); + info.cellX, info.cellY); } } @@ -1084,7 +1093,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList public void run() { CellLayout cellLayout = mLauncher.getCellLayout(mInfo.container, mInfo.screenId); - View child = null; + View child = null; // Move the item from the folder to the workspace, in the position of the folder if (getItemCount() == 1) { ShortcutInfo finalItem = mInfo.contents.get(0); @@ -1114,6 +1123,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList View finalChild = getItemAt(0); if (finalChild != null) { mFolderIcon.performDestroyAnimation(finalChild, onCompleteRunnable); + } else { + onCompleteRunnable.run(); } mDestroyed = true; } diff --git a/src/com/android/launcher3/FolderInfo.java b/src/com/android/launcher3/FolderInfo.java index bb5ae8200..d45e4e47b 100644 --- a/src/com/android/launcher3/FolderInfo.java +++ b/src/com/android/launcher3/FolderInfo.java @@ -16,10 +16,10 @@ package com.android.launcher3; -import java.util.ArrayList; - import android.content.ContentValues; +import java.util.ArrayList; + /** * Represents a folder containing shortcuts or apps. */ diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 9c9a6959f..4e01996ee 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -593,8 +593,9 @@ public class LauncherModel extends BroadcastReceiver { // as in Workspace.onDrop. Here, we just add/remove them from the list of items // that are on the desktop, as appropriate ItemInfo modelItem = sBgItemsIdMap.get(itemId); - if (modelItem.container == LauncherSettings.Favorites.CONTAINER_DESKTOP || - modelItem.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { + if (modelItem != null && + (modelItem.container == LauncherSettings.Favorites.CONTAINER_DESKTOP || + modelItem.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT)) { switch (modelItem.itemType) { case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: |