mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Fix remainingPlaybackAnimationMs crash (#7836)
This happens when trying to round `Float.NaN` to `Int`
This commit is contained in:
committed by
GitHub
parent
558c4541cd
commit
a12977b4dc
+4
-2
@@ -152,8 +152,10 @@ internal fun remainingPlaybackAnimationMs(
|
|||||||
durationMs: Long,
|
durationMs: Long,
|
||||||
playbackSpeed: Float,
|
playbackSpeed: Float,
|
||||||
): Int {
|
): Int {
|
||||||
val remainingProgress = (1f - progress).coerceAtLeast(0f)
|
if (!progress.isFinite() || !playbackSpeed.isFinite() || durationMs <= 0L) return 0
|
||||||
return (remainingProgress * durationMs / playbackSpeed.coerceAtLeast(0.01f))
|
val remainingProgress = (1f - progress).coerceIn(0f, 1f)
|
||||||
|
val speed = playbackSpeed.coerceAtLeast(0.01f)
|
||||||
|
return (remainingProgress * durationMs / speed)
|
||||||
.roundToInt()
|
.roundToInt()
|
||||||
.coerceAtLeast(0)
|
.coerceAtLeast(0)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user