I just write a code and use async and await for downloading image. But android studio telling me to use withcontext for this. You can see the code below. But there is already one dispatchers.IO in code. Already we are in IO Scope, why we use again withContext? Is this the really good practice? Code just looks weird.
CoroutineScope(Dispatchers.IO).launch {
val test = withContext(Dispatchers.IO) {
val link =
"https://i.pinimg.com/originals/3b/8a/d2/3b8ad2c7b1be2caf24321c852103598a.jpg"
ImageProgress.downloadImageToBitmap(link, this@MainActivity)
}
runOnUiThread {
Glide.with(this@MainActivity)
.load(test)
.into(binding.imageView)
}
}