Prevent calculating folder centers when there are no items

This commit is contained in:
Ensar Sarajčić 2023-09-21 15:07:14 +02:00
parent 28e0f2d59f
commit 0a239b1d06
1 changed files with 4 additions and 0 deletions

View File

@ -1588,6 +1588,10 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
fun getItemsGridCenters(): List<Triple<Int, Int, Int>> {
val count = getItems().count()
if (count == 0) {
return emptyList()
}
val columnsCount = ceil(sqrt(count.toDouble())).roundToInt()
val rowsCount = ceil(count.toFloat() / columnsCount).roundToInt()
val folderItemsRect = getItemsDrawingRect()