Only consider top level items when finding first empty cell

This commit is contained in:
Ensar Sarajčić 2023-09-21 12:52:21 +02:00
parent 4f5fda2c52
commit d9e333ddb0
1 changed files with 2 additions and 2 deletions

View File

@ -405,9 +405,9 @@ class MainActivity : SimpleActivity(), FlingListener {
private fun findFirstEmptyCell(): Pair<Int, Rect> {
val gridItems = homeScreenGridItemsDB.getAllItems() as ArrayList<HomeScreenGridItem>
val maxPage = gridItems.map { it.page }.max()
val maxPage = gridItems.maxOf { it.page }
val occupiedCells = ArrayList<Triple<Int, Int, Int>>()
gridItems.forEach { item ->
gridItems.filter { it.parentId == null }.forEach { item ->
for (xCell in item.left..item.right) {
for (yCell in item.top..item.bottom) {
occupiedCells.add(Triple(item.page, xCell, yCell))