mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-15 07:28:30 +00:00
Fix sticker grid sometimes getting stuck on 2 columns.
This commit is contained in:
committed by
Michelle Tang
parent
20a05220ea
commit
611b52780e
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user