From d9e333ddb0543e4a3a4b71e4d05fba9c65e791ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 21 Sep 2023 12:52:21 +0200 Subject: [PATCH] Only consider top level items when finding first empty cell --- .../com/simplemobiletools/launcher/activities/MainActivity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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))