Commit 78a28f77 authored by Romain Hunault's avatar Romain Hunault
Browse files

Merge branch '4286-blisslauncher_folder_fix' into 'master'

Fix IndexOutOfBoundsException while loading items

See merge request !76
parents 078209a9 2ff37d27
Pipeline #180892 passed with stage
in 2 minutes and 36 seconds
......@@ -140,7 +140,7 @@ public class LauncherItem {
@Override
public String toString() {
return "[id: " + id + "item_type: " + itemType + ", container: " + container + ", screen: " + screenId
return "[id: " + id + ", item_type: " + itemType + ", container: " + container + ", screen: " + screenId
+ ", cell: " + cell + "]";
}
......
......@@ -337,6 +337,8 @@ public class AppProvider {
if (index != null) {
FolderItem folderItem = (FolderItem) mLauncherItems.get(index);
folderItem.items.add(applicationItem);
} else {
Log.e("AppProvider", "folder not found for item: " + applicationItem.id);
}
}
} else if (databaseItem.itemType == Constants.ITEM_TYPE_SHORTCUT) {
......@@ -377,17 +379,22 @@ public class AppProvider {
}
}
if (foldersIndex.size() > 0) {
for (int i = 0; i < foldersIndex.size(); i++) {
FolderItem folderItem =
(FolderItem) mLauncherItems.get(foldersIndex.get(foldersIndex.keyAt(i)));
if (folderItem.items == null || folderItem.items.size() == 0) {
DatabaseManager.getManager(mContext).removeLauncherItem(folderItem.id);
mLauncherItems.remove((int) foldersIndex.get(foldersIndex.keyAt(i)));
} else {
folderItem.icon = new GraphicsUtil(mContext).generateFolderIcon(mContext,
folderItem);
}
List<Integer> folderItemsIndex = new ArrayList<>();
for (int i = 0; i < foldersIndex.size(); i++) {
int itemIndex = foldersIndex.get(foldersIndex.keyAt(i));
folderItemsIndex.add(itemIndex);
}
Collections.sort(folderItemsIndex);
for (int i = folderItemsIndex.size() - 1; i >= 0; i--) {
int itemIndex = folderItemsIndex.get(i);
FolderItem folderItem =
(FolderItem) mLauncherItems.get(itemIndex);
if (folderItem.items == null || folderItem.items.size() == 0) {
DatabaseManager.getManager(mContext).removeLauncherItem(folderItem.id);
mLauncherItems.remove(itemIndex);
} else {
folderItem.icon = new GraphicsUtil(mContext).generateFolderIcon(mContext,
folderItem);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment