From 0c2598d37b2d3551aac502f2e4c7772e3c3a02e0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 10 Feb 2017 23:59:28 +0100 Subject: [PATCH] show error messages if deleting failed --- .../gallery/activities/MediaActivity.kt | 11 +++++++++-- .../gallery/activities/ViewPagerActivity.kt | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index b5befb43f..cd4679e3a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -235,6 +235,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } Thread({ + var hadSuccess = false files.filter { it.exists() && it.isImageVideoGif() } .forEach { if (needsPermissions) { @@ -244,13 +245,19 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { val uri = URLDecoder.decode(document.uri.toString(), "UTF-8") val filename = URLDecoder.decode(it.absolutePath.getFilenameFromPath(), "UTF-8") if (uri.endsWith(filename) && !document.isDirectory) { - document.delete() + if (document.delete()) + hadSuccess = true } } else { - it.delete() + if (it.delete()) + hadSuccess = true } deleteFromMediaStore(it) } + if (!hadSuccess) + runOnUiThread { + toast(R.string.unknown_error_occurred) + } }).start() if (mMedia.isEmpty()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index f2670380d..d089a296f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -246,6 +246,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View val filename = URLDecoder.decode(file.absolutePath.getFilenameFromPath(), "UTF-8") if (uri.endsWith(filename) && !document.isDirectory) { document.delete() + } else { + runOnUiThread { + toast(R.string.unknown_error_occurred) + } + return@Thread } } else { file.delete()