From 6766e46c37821cef73fc583d8245bed8831cc1ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 21 Sep 2023 12:03:19 +0200 Subject: [PATCH] Prevent generating drawables for empty folders --- .../simplemobiletools/launcher/views/HomeScreenGrid.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt index 6d06571..736c990 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt @@ -1502,13 +1502,18 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel return null } + val items = getItems() + val itemsCount = getItems().count() + + if (itemsCount == 0) { + return null + } + val bitmap = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888) val canvas = Canvas(bitmap) val circlePath = Path().apply { addCircle((iconSize / 2).toFloat(), (iconSize / 2).toFloat(), (iconSize / 2).toFloat(), Path.Direction.CCW) } canvas.clipPath(circlePath) canvas.drawPaint(folderIconBackgroundPaint) - val items = getItems() - val itemsCount = getItems().count() val folderColumnCount = ceil(sqrt(itemsCount.toDouble())).roundToInt() val folderRowCount = ceil(itemsCount.toFloat() / folderColumnCount).roundToInt() val scaledCellSize = (iconSize.toFloat() / folderColumnCount)