Skip to content

Commit 7214bf6

Browse files
author
Jan Guegel
committed
use ensureBackgroundThread to avoid ANR on large files
Signed-off-by: Jan Guegel <[email protected]>
1 parent 54b8912 commit 7214bf6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,16 @@ class ReadTextActivity : SimpleActivity() {
231231
}
232232

233233
val text = binding.readTextView.text.toString()
234-
val base64 = Base64.encodeToString(text.toByteArray(), Base64.DEFAULT)
235-
webView.loadData(base64, "text/plain", "base64")
234+
ensureBackgroundThread {
235+
try {
236+
val base64 = Base64.encodeToString(text.toByteArray(), Base64.DEFAULT)
237+
runOnUiThread {
238+
webView.loadData(base64, "text/plain", "base64")
239+
}
240+
} catch (e: Exception) {
241+
showErrorToast(e)
242+
}
243+
}
236244
} catch (e: Exception) {
237245
showErrorToast(e)
238246
}

0 commit comments

Comments
 (0)