Fixed using Composable's scope instead of GlobalScope
This commit is contained in:
parent
e3a6cd7df2
commit
d12cb7269b
|
@ -44,6 +44,8 @@ fun ChipTanFlickerCodeView(flickerCode: FlickerCode, textColor: Color = Color.Bl
|
|||
|
||||
var step by remember { mutableStateOf(Step(Bit.High, Bit.High, Bit.High, Bit.High, Bit.High)) }
|
||||
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
|
||||
fun setSize(width: Dp, height: Dp, spaceBetween: Dp) {
|
||||
stripesWidth = width
|
||||
|
@ -157,7 +159,7 @@ fun ChipTanFlickerCodeView(flickerCode: FlickerCode, textColor: Color = Color.Bl
|
|||
DisposableEffect(animator) {
|
||||
animator.setFrequency(frequency)
|
||||
|
||||
animator.animateFlickerCode(flickerCode) {
|
||||
animator.animateFlickerCode(flickerCode, coroutineScope) {
|
||||
step = it
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ class FlickerCodeAnimator {
|
|||
|
||||
|
||||
|
||||
fun animateFlickerCode(flickerCode: FlickerCode, showStep: (Step) -> Unit) { // TODO: find better coroutine scope
|
||||
fun animateFlickerCode(flickerCode: FlickerCode, scope: CoroutineScope , showStep: (Step) -> Unit) {
|
||||
stop() // stop may still running previous animation
|
||||
|
||||
flickerCode.parsedDataSet?.let { parsedDataSet ->
|
||||
animationJob = GlobalScope.launch(Dispatchers.Default) {
|
||||
animationJob = scope.launch(Dispatchers.Default) {
|
||||
val steps = FlickerCodeStepsCalculator().calculateSteps(parsedDataSet)
|
||||
|
||||
calculateAnimation(steps, showStep)
|
||||
|
|
Loading…
Reference in New Issue