Initial Changes for Dynamic Grid
Change-Id: I9e6f1e5167791cf8dc140778dfa447f86424e9bf
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 2ac9b1b..cd37a16 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1556,6 +1556,11 @@
}
}
+ private boolean checkItemDimensions(ItemInfo info) {
+ return (info.cellX + info.spanX) > mCellCountX ||
+ (info.cellY + info.spanY) > mCellCountY;
+ }
+
// check & update map of what's occupied; used to discard overlapping/invalid items
private boolean checkItemPlacement(HashMap<Long, ItemInfo[][]> occupied, ItemInfo item) {
long containerIndex = item.screenId;
@@ -1743,6 +1748,16 @@
info.screenId = c.getInt(screenIndex);
info.cellX = c.getInt(cellXIndex);
info.cellY = c.getInt(cellYIndex);
+ info.spanX = 1;
+ info.spanY = 1;
+ // Skip loading items that are out of bounds
+ if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
+ if (checkItemDimensions(info)) {
+ Log.d(TAG, "Skipped loading out of bounds shortcut: "
+ + info.intent);
+ continue;
+ }
+ }
// check & update map of what's occupied
if (!checkItemPlacement(occupied, info)) {
break;
@@ -1781,11 +1796,22 @@
folderInfo.screenId = c.getInt(screenIndex);
folderInfo.cellX = c.getInt(cellXIndex);
folderInfo.cellY = c.getInt(cellYIndex);
+ folderInfo.spanX = 1;
+ folderInfo.spanY = 1;
+ // Skip loading items that are out of bounds
+ if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
+ int iconSpan = 1;
+ if (checkItemDimensions(folderInfo)) {
+ Log.d(TAG, "Skipped loading out of bounds folder");
+ continue;
+ }
+ }
// check & update map of what's occupied
if (!checkItemPlacement(occupied, folderInfo)) {
break;
}
+
switch (container) {
case LauncherSettings.Favorites.CONTAINER_DESKTOP:
case LauncherSettings.Favorites.CONTAINER_HOTSEAT:
@@ -1834,6 +1860,13 @@
}
appWidgetInfo.container = c.getInt(containerIndex);
+ // Skip loading items that are out of bounds
+ if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
+ if (checkItemDimensions(appWidgetInfo)) {
+ Log.d(TAG, "Skipped loading out of bounds app widget");
+ continue;
+ }
+ }
// check & update map of what's occupied
if (!checkItemPlacement(occupied, appWidgetInfo)) {
break;