Fix crash when spamming taps during reordering
This commit is contained in:
@@ -21,18 +21,18 @@ class AnimatablesPool<T, V : AnimationVector>(
|
|||||||
require(size > 0)
|
require(size > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun acquire(): Animatable<T, V> {
|
suspend fun acquire(): Animatable<T, V>? {
|
||||||
return mutex.withLock {
|
return mutex.withLock {
|
||||||
require(values.isNotEmpty())
|
if (values.isNotEmpty()) values.removeFirst() else null
|
||||||
values.removeFirst()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun release(animatable: Animatable<T, V>) {
|
suspend fun release(animatable: Animatable<T, V>) {
|
||||||
mutex.withLock {
|
mutex.withLock {
|
||||||
require(values.size < size)
|
if (values.size < size) {
|
||||||
animatable.snapTo(initialValue)
|
animatable.snapTo(initialValue)
|
||||||
values.add(animatable)
|
values.add(animatable)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user