Fix sticker grid sometimes getting stuck on 2 columns.

This commit is contained in:
Greyson Parrelli
2026-02-10 13:12:44 -05:00
committed by Michelle Tang
parent 20a05220ea
commit 611b52780e
2 changed files with 22 additions and 3 deletions

View File

@@ -203,11 +203,20 @@ open class StickerKeyboardPageFragment :
}
override fun onLayoutChange(v: View?, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int) {
onScreenWidthChanged(view?.width ?: 0)
onScreenWidthChanged(right - left)
}
private fun onScreenWidthChanged(@Px newWidth: Int) {
layoutManager.spanCount = calculateColumnCount(newWidth)
if (newWidth <= 0) {
return
}
val newSpanCount = calculateColumnCount(newWidth)
if (layoutManager.spanCount != newSpanCount) {
stickerList.post {
layoutManager.spanCount = newSpanCount
}
}
}
private fun calculateColumnCount(@Px screenWidth: Int): Int {

View File

@@ -79,7 +79,17 @@ class StickerSearchDialogFragment : DialogFragment(), KeyboardStickerListAdapter
}
override fun onLayoutChange(v: View?, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int) {
layoutManager.spanCount = calculateColumnCount(view?.width ?: 0)
val width = right - left
if (width <= 0) {
return
}
val newSpanCount = calculateColumnCount(width)
if (layoutManager.spanCount != newSpanCount) {
list.post {
layoutManager.spanCount = newSpanCount
}
}
}
private fun calculateColumnCount(@Px screenWidth: Int): Int {