show error messages if deleting failed

This commit is contained in:
tibbi 2017-02-10 23:59:28 +01:00
parent 67a459ced7
commit 0c2598d37b
2 changed files with 14 additions and 2 deletions

View file

@ -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()) {

View file

@ -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()