From 8ff9e7f6adabdabae84596bfeba36aa53113582b Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 22 Apr 2018 23:08:36 +0200 Subject: [PATCH] fix some Rename related glitches --- .../com/simplemobiletools/gallery/extensions/Activity.kt | 5 ++++- .../com/simplemobiletools/gallery/interfaces/MediumDao.kt | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt index 01a510955..b6ecd4d35 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt @@ -148,9 +148,12 @@ fun BaseSimpleActivity.toggleFileVisibility(oldPath: String, hide: Boolean, call filename.substring(1, filename.length) } - val newPath = "$path$filename" + val newPath = "$path/$filename" renameFile(oldPath, newPath) { callback?.invoke(newPath) + Thread { + updateMediaPath(oldPath, newPath) + }.start() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/MediumDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/MediumDao.kt index cd2cb1564..da7612e52 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/MediumDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/MediumDao.kt @@ -23,6 +23,6 @@ interface MediumDao { @Query("DELETE FROM media WHERE full_path = :path") fun deleteMediumPath(path: String) - @Query("UPDATE media SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath") + @Query("UPDATE OR REPLACE media SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath") fun updateMedia(oldPath: String, newParentPath: String, newFilename: String, newFullPath: String) }