Fix grid size when entering library without animation

Closes #1228
This commit is contained in:
Jays2Kings 2022-05-01 23:31:04 -04:00
parent 39b860f4c8
commit c175219bb9

View file

@ -43,8 +43,8 @@ class AutofitRecyclerView @JvmOverloads constructor(context: Context, attrs: Att
val itemWidth: Int
get() {
return if (spanCount == 0) measuredWidth / getTempSpan()
else measuredWidth / managerSpanCount
return if (width == 0) measuredWidth / getTempSpan()
else width / managerSpanCount
}
init {
@ -61,7 +61,7 @@ class AutofitRecyclerView @JvmOverloads constructor(context: Context, attrs: Att
}
private fun getTempSpan(): Int {
if (spanCount == 0 && columnWidth > 0) {
if (columnWidth > 0) {
val dpWidth = (measuredWidth.toFloat().pxToDp / 100f).roundToInt()
return max(1, (dpWidth / columnWidth).roundToInt())
}