From c46ffc4ef5232c6fbec741de49af5134c982b20b Mon Sep 17 00:00:00 2001 From: Emil Arfvidsson Date: Thu, 14 Sep 2023 11:20:21 -0700 Subject: [PATCH] Finish animation ignoring cancellation. --- .../com/bumptech/glide/integration/compose/Transition.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/integration/compose/src/main/java/com/bumptech/glide/integration/compose/Transition.kt b/integration/compose/src/main/java/com/bumptech/glide/integration/compose/Transition.kt index 8b30e0bfa9..3fc938d205 100644 --- a/integration/compose/src/main/java/com/bumptech/glide/integration/compose/Transition.kt +++ b/integration/compose/src/main/java/com/bumptech/glide/integration/compose/Transition.kt @@ -12,6 +12,8 @@ import androidx.compose.ui.graphics.drawscope.DrawScope import androidx.compose.ui.graphics.drawscope.clipRect import androidx.compose.ui.graphics.drawscope.translate import androidx.compose.ui.graphics.painter.Painter +import kotlinx.coroutines.NonCancellable +import kotlinx.coroutines.withContext /** * Transition between a given request's optional placeholder and the resource. @@ -141,7 +143,9 @@ internal class CrossFadeImpl( animatable.animateTo(OPAQUE_ALPHA, animationSpec) invalidate() } finally { - animatable.snapTo(OPAQUE_ALPHA) + withContext(NonCancellable) { + animatable.snapTo(OPAQUE_ALPHA) + } invalidate() } } @@ -161,4 +165,4 @@ internal class CrossFadeImpl( draw(size, animatable.value * alpha, colorFilter) } } -} \ No newline at end of file +}