diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt index 3a0cee5..1eaea4c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt @@ -405,9 +405,9 @@ class MainActivity : SimpleActivity(), FlingListener { private fun findFirstEmptyCell(): Pair { val gridItems = homeScreenGridItemsDB.getAllItems() as ArrayList - val maxPage = gridItems.map { it.page }.max() + val maxPage = gridItems.maxOf { it.page } val occupiedCells = ArrayList>() - 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))