From bb7a911df1b6ef8eff0273e6aa2a7231ef33260b Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 2 Oct 2018 21:33:01 +0200 Subject: [PATCH] fix #971, keep items as Favorites at move --- .../gallery/activities/ViewPagerActivity.kt | 1 + .../simplemobiletools/gallery/adapters/MediaAdapter.kt | 1 + .../com/simplemobiletools/gallery/extensions/Activity.kt | 9 +++++++++ 3 files changed, 11 insertions(+) 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 f35a6012f..7604f2340 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -527,6 +527,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View config.tempFolderPath = "" if (!isCopyOperation) { refreshViewPager() + updateFavoritePaths(fileDirItems, it) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 6ec1bd548..d88895b59 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -283,6 +283,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList Unit) { callback() } } + +fun BaseSimpleActivity.updateFavoritePaths(fileDirItems: ArrayList, destination: String) { + Thread { + fileDirItems.forEach { + val newPath = "$destination/${it.name}" + updateDBMediaPath(it.path, newPath) + } + }.start() +}