catch exceptions thrown at clearing the recycle bin

This commit is contained in:
tibbi 2019-06-27 09:52:11 +02:00
parent 44014ef44a
commit f066f4b84a

View file

@ -293,11 +293,15 @@ fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList<String>, mediumDa
fun BaseSimpleActivity.emptyTheRecycleBin(callback: (() -> Unit)? = null) {
Thread {
recycleBin.deleteRecursively()
galleryDB.MediumDao().clearRecycleBin()
galleryDB.DirectoryDao().deleteRecycleBin()
toast(R.string.recycle_bin_emptied)
callback?.invoke()
try {
recycleBin.deleteRecursively()
galleryDB.MediumDao().clearRecycleBin()
galleryDB.DirectoryDao().deleteRecycleBin()
toast(R.string.recycle_bin_emptied)
callback?.invoke()
} catch (e: Exception) {
toast(R.string.unknown_error_occurred)
}
}.start()
}