Okio source cannot be read inside a Kotlin Coroutine
I am trying to generate a Bitmap from an Okio source using this implementation
val file = /* ... */
Okio.source(file).use {
CoroutineScope(
Dispatchers.IO).launch {
Okio.buffer(source).use { bufferedSource ->
val bitmap = BitmapFactory.decodeStream(bufferedSource.inputStream())
withContext(Dispatchers.Main) {
view.setImageBitmap(bitmap)
}
}
}
}
Thing is, the resulting bitmap is null and I get the following...