Deleting workspace items from db which have an invalid placement
Change-Id: I1d616e8cd533acd6ecd334d85e6468163f31f6a4
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index f747423..3055dd0 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1758,8 +1758,7 @@
}
// check & update map of what's occupied; used to discard overlapping/invalid items
- private boolean checkItemPlacement(HashMap<Long, ItemInfo[][]> occupied, ItemInfo item,
- AtomicBoolean deleteOnInvalidPlacement) {
+ private boolean checkItemPlacement(HashMap<Long, ItemInfo[][]> occupied, ItemInfo item) {
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
final int countX = (int) grid.numColumns;
@@ -1770,7 +1769,6 @@
// Return early if we detect that an item is under the hotseat button
if (mCallbacks == null ||
mCallbacks.get().isAllAppsButtonRank((int) item.screenId)) {
- deleteOnInvalidPlacement.set(true);
Log.e(TAG, "Error loading shortcut into hotseat " + item
+ " into position (" + item.screenId + ":" + item.cellX + ","
+ item.cellY + ") occupied by all apps");
@@ -1967,7 +1965,6 @@
UserHandleCompat user;
while (!mStopped && c.moveToNext()) {
- AtomicBoolean deleteOnInvalidPlacement = new AtomicBoolean(false);
try {
int itemType = c.getInt(itemTypeIndex);
boolean restored = 0 != c.getInt(restoredIndex);
@@ -2145,11 +2142,8 @@
}
// check & update map of what's occupied
- deleteOnInvalidPlacement.set(false);
- if (!checkItemPlacement(occupied, info, deleteOnInvalidPlacement)) {
- if (deleteOnInvalidPlacement.get()) {
- itemsToRemove.add(id);
- }
+ if (!checkItemPlacement(occupied, info)) {
+ itemsToRemove.add(id);
break;
}
@@ -2190,12 +2184,8 @@
folderInfo.spanY = 1;
// check & update map of what's occupied
- deleteOnInvalidPlacement.set(false);
- if (!checkItemPlacement(occupied, folderInfo,
- deleteOnInvalidPlacement)) {
- if (deleteOnInvalidPlacement.get()) {
- itemsToRemove.add(id);
- }
+ if (!checkItemPlacement(occupied, folderInfo)) {
+ itemsToRemove.add(id);
break;
}
@@ -2303,12 +2293,8 @@
appWidgetInfo.container = c.getInt(containerIndex);
// check & update map of what's occupied
- deleteOnInvalidPlacement.set(false);
- if (!checkItemPlacement(occupied, appWidgetInfo,
- deleteOnInvalidPlacement)) {
- if (deleteOnInvalidPlacement.get()) {
- itemsToRemove.add(id);
- }
+ if (!checkItemPlacement(occupied, appWidgetInfo)) {
+ itemsToRemove.add(id);
break;
}