From 308755c5ba1c45bc661519439d18d62362f76bd2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 31 Mar 2018 10:38:13 +0200 Subject: [PATCH] make sure the file exists before trying to read it at the read activity --- .../filemanager/activities/ReadTextActivity.kt | 8 +++++++- .../filemanager/adapters/ItemsAdapter.kt | 6 +++--- .../filemanager/adapters/ManageFavoritesAdapter.kt | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/ReadTextActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/ReadTextActivity.kt index 88192c4d..6b3724bd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/ReadTextActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/ReadTextActivity.kt @@ -80,7 +80,13 @@ class ReadTextActivity : SimpleActivity() { val text = if (uri.scheme == "file") { filePath = uri.path - File(uri.path).readText() + val file = File(filePath) + if (file.exists()) { + file.readText() + } else { + toast(R.string.unknown_error_occurred) + "" + } } else { try { contentResolver.openInputStream(uri).bufferedReader().use { it.readText() } diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt index 45f76164..425fe68e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt @@ -95,7 +95,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList