From 0ef9ff06bf9583583052cf4d4068e37fecc4ec5a Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 30 Sep 2017 22:33:58 +0200 Subject: [PATCH] refresh directories instantly after un/pinning --- .../simplemobiletools/gallery/activities/MainActivity.kt | 4 ++++ .../simplemobiletools/gallery/adapters/DirectoryAdapter.kt | 4 +++- .../com/simplemobiletools/gallery/extensions/context.kt | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 0694bbc53..0ca8e74a9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -552,6 +552,10 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { directories_grid.setDragSelectActive(position) } + override fun recheckPinnedFolders() { + gotDirectories(movePinnedDirectoriesToFront(mDirs), true) + } + private fun checkWhatsNewDialog() { arrayListOf().apply { add(Release(46, R.string.release_46)) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index cf0a6fad1..9454f0ca4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -221,7 +221,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList) fun itemLongClicked(position: Int) + + fun recheckPinnedFolders() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt index c04c3371e..f7cd61529 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -75,7 +75,11 @@ fun Context.movePinnedDirectoriesToFront(dirs: ArrayList): ArrayList< val foundFolders = ArrayList() val pinnedFolders = config.pinnedFolders - dirs.forEach { if (pinnedFolders.contains(it.path)) foundFolders.add(it) } + dirs.forEach { + if (pinnedFolders.contains(it.path)) + foundFolders.add(it) + } + dirs.removeAll(foundFolders) dirs.addAll(0, foundFolders) return dirs