'Why this Kotlin Coroutine is freezing the interface?
So, I had this code running inside a "onBindViewHolder" recycler's adapter method:
launch(UI) {
val bitmapDrawable = loadLargeBitmapDrawable()
imageView.setImageDrawable(bitmapDrawable)
}
This was freezing my app for some seconds, locking my mainthread.
But then I changed to this:
launch { // <- I removed the "UI"
val bitmapDrawable = loadLargeBitmapDrawable()
launch(UI) { //Launch the UI coroutine inside the other
imageView.setImageDrawable(bitmapDrawable)
}
}
Why this is happening? The purpose of coroutines are to make things async inside the same thread (UI) right? Someone can explain me why I had to run a UI coroutine inside another coroutine scope ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
