From bb943daf38b91c6c2b0ee0e21d409324f8338f0a Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 26 Apr 2018 10:46:35 +0200 Subject: [PATCH] remove a directory from local db if it is empty --- .../simplemobiletools/gallery/activities/MediaActivity.kt | 8 ++++++++ 1 file changed, 8 insertions(+) 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 4bc667bc5..63ce77841 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -485,6 +485,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun isDirEmpty(): Boolean { return if (mMedia.size <= 0 && config.filterMedia > 0) { deleteDirectoryIfEmpty() + deleteDBDirectory() finish() true } else { @@ -492,6 +493,12 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } } + private fun deleteDBDirectory() { + Thread { + galleryDB.DirectoryDao().deleteDirPath(mPath) + }.start() + } + private fun tryToggleTemporarilyShowHidden() { if (config.temporarilyShowHidden) { toggleTemporarilyShowHidden(false) @@ -671,6 +678,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { toast(R.string.unknown_error_occurred) } else if (mMedia.isEmpty()) { deleteDirectoryIfEmpty() + deleteDBDirectory() finish() } else { Thread {