Prevent drawing empty folders

This commit is contained in:
Ensar Sarajčić 2023-08-22 14:43:03 +02:00
parent 81dff807b4
commit a7ffb6328a
1 changed files with 5 additions and 2 deletions

View File

@ -1536,8 +1536,11 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
private fun HomeScreenGridItem.getFolderRect(): RectF {
val count = getFolderItems().count()
val columnsCount = ceil(sqrt(count.toDouble())).roundToInt()
val rowsCount = ceil(count.toFloat() / columnsCount).roundToInt()
if (count == 0) {
return RectF(0f, 0f, 0f, 0f)
}
val columnsCount = ceil(sqrt(count.toDouble())).toInt()
val rowsCount = ceil(count.toFloat() / columnsCount).toInt()
val centerX = cellXCoords[left] + cellWidth / 2 + sideMargins.left
val centerY = cellYCoords[top] + cellHeight / 2 + sideMargins.top
val folderDialogWidth = (columnsCount * cellWidth + 2 * folderPadding)