Remove widgets that are out of bounds if they are blocking dropped icon

This commit is contained in:
Ensar Sarajčić 2023-09-22 13:27:26 +02:00
parent 2349fa019c
commit 200109e527

View File

@ -531,9 +531,20 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
if (isAnyCellOccupied) {
if (item.type != ITEM_TYPE_WIDGET && !item.docked) {
potentialParent = item
} else {
if (item.type == ITEM_TYPE_WIDGET && item.outOfBounds()) {
ensureBackgroundThread {
removeItemFromHomeScreen(item)
post {
removeView(widgetViews.firstOrNull { it.tag == item.widgetId })
widgetViews.removeIf { it.tag == item.widgetId }
}
gridItems.removeIf { it.id == item.id }
}
} else {
isDroppingPositionValid = false
}
}
return@forEach
}
}