Fix crash when spamming taps during reordering
This commit is contained in:
parent
b50c54b1ed
commit
2d94b06fc2
1 changed files with 6 additions and 6 deletions
|
@ -21,18 +21,18 @@ class AnimatablesPool<T, V : AnimationVector>(
|
|||
require(size > 0)
|
||||
}
|
||||
|
||||
suspend fun acquire(): Animatable<T, V> {
|
||||
suspend fun acquire(): Animatable<T, V>? {
|
||||
return mutex.withLock {
|
||||
require(values.isNotEmpty())
|
||||
values.removeFirst()
|
||||
if (values.isNotEmpty()) values.removeFirst() else null
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun release(animatable: Animatable<T, V>) {
|
||||
mutex.withLock {
|
||||
require(values.size < size)
|
||||
animatable.snapTo(initialValue)
|
||||
values.add(animatable)
|
||||
if (values.size < size) {
|
||||
animatable.snapTo(initialValue)
|
||||
values.add(animatable)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue