Properly shift folder items when removing items from folder

This commit is contained in:
Ensar Sarajčić 2023-09-21 14:01:50 +02:00
parent 571f1c1af4
commit f8fccf9444
1 changed files with 7 additions and 0 deletions

View File

@ -242,6 +242,13 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
ensureBackgroundThread { ensureBackgroundThread {
if (item.id != null) { if (item.id != null) {
context.homeScreenGridItemsDB.deleteById(item.id!!) context.homeScreenGridItemsDB.deleteById(item.id!!)
if (item.parentId != null) {
gridItems.filter { it.parentId == item.parentId && it.left > item.left && it.id != item.id }.forEach {
it.left -= 1
}
context.homeScreenGridItemsDB.shiftFolderItems(item.parentId!!, item.left, -1, item.id)
}
} }
if (item.type == ITEM_TYPE_WIDGET) { if (item.type == ITEM_TYPE_WIDGET) {