From 5fbcf7f7fabddfd55d959de5278ca635f66c536b Mon Sep 17 00:00:00 2001 From: Danesh M Date: Fri, 31 Jan 2014 15:22:05 -0800 Subject: Launcher3 : checkItemPlacement fixes This patchset addresses two bugs : 1) Incorrect casting of key causes mismatches 2) On hotseat items 2 and above, the occupied hashmap is populated with the CONTAINER_HOTSEAT key, however if its a new item and its required cell is not already been taken, the code falls through to the workspace checks. Make sure hotseat items are treated separately. Change-Id: I1898c6d688cc428a355fdf062218fcda40da98e4 --- src/com/android/launcher3/LauncherModel.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/com/android/launcher3/LauncherModel.java') diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 5b2ba588c..ee808df63 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -1313,19 +1313,24 @@ public class LauncherModel extends BroadcastReceiver { long containerIndex = item.screenId; if (item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { - if (occupied.containsKey(LauncherSettings.Favorites.CONTAINER_HOTSEAT)) { - if (occupied.get(LauncherSettings.Favorites.CONTAINER_HOTSEAT) + if (occupied.containsKey((long) LauncherSettings.Favorites.CONTAINER_HOTSEAT)) { + if (occupied.get((long) LauncherSettings.Favorites.CONTAINER_HOTSEAT) [(int) item.screenId][0] != null) { Log.e(TAG, "Error loading shortcut into hotseat " + item + " into position (" + item.screenId + ":" + item.cellX + "," + item.cellY + ") occupied by " - + occupied.get(LauncherSettings.Favorites.CONTAINER_HOTSEAT) + + occupied.get((long) LauncherSettings.Favorites.CONTAINER_HOTSEAT) [(int) item.screenId][0]); if (occupied.get(LauncherSettings.Favorites.CONTAINER_HOTSEAT) [(int) item.screenId][0].itemType == LauncherSettings.Favorites.ITEM_TYPE_ALLAPPS) { deleteOnItemOverlap.set(true); } return false; + } else { + ItemInfo[][] hotseatItems = occupied.get( + (long) LauncherSettings.Favorites.CONTAINER_HOTSEAT); + hotseatItems[(int) item.screenId][0] = item; + return true; } } else { ItemInfo[][] items = new ItemInfo[countX + 1][countY + 1]; -- cgit v1.2.3