run openInputstream in IO context

hauntED
yova 4 months ago
parent da60d7395e
commit 2b816a923d

@ -991,6 +991,8 @@ class MainActivity : AppCompatActivity() {
})
}
try {
CoroutineScope(Dispatchers.Main).launch {
withContext(Dispatchers.IO) {
contentResolver.openInputStream(uri)?.use { inputStream ->
BufferedReader(InputStreamReader(inputStream)).use { reader ->
var i = ""
@ -1005,6 +1007,8 @@ class MainActivity : AppCompatActivity() {
}
}
}
}
}
} catch (e: java.io.FileNotFoundException) {
Log.d(javaClass.simpleName, "File not found during reading:\n${e.stackTraceToString()}")
this.runOnUiThread({

Loading…
Cancel
Save