mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 03:16:02 +03:00
disabling user input whilst the automatic animation is taking place, fixes crashes when user input is attempted at the same time
This commit is contained in:
parent
bdb41b253d
commit
a0bda02824
1 changed files with 3 additions and 1 deletions
|
@ -27,7 +27,7 @@ fun ViewPager2.setCurrentItem(
|
|||
item: Int,
|
||||
duration: Long,
|
||||
interpolator: TimeInterpolator = AccelerateDecelerateInterpolator(),
|
||||
pagePxWidth: Int = width // Default value taken from getWidth() from ViewPager2 view
|
||||
pagePxWidth: Int = width,
|
||||
) {
|
||||
val pxToDrag: Int = pagePxWidth * (item - currentItem)
|
||||
val animator = ValueAnimator.ofInt(0, pxToDrag)
|
||||
|
@ -47,10 +47,12 @@ fun ViewPager2.setCurrentItem(
|
|||
}
|
||||
animator.addListener(object : Animator.AnimatorListener {
|
||||
override fun onAnimationStart(animation: Animator?) {
|
||||
isUserInputEnabled = false
|
||||
beginFakeDrag()
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
isUserInputEnabled = true
|
||||
endFakeDrag()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue