refresh directories instantly after un/pinning

This commit is contained in:
tibbi 2017-09-30 22:33:58 +02:00
parent 5c7dfb87be
commit 0ef9ff06bf
3 changed files with 12 additions and 2 deletions

View File

@ -552,6 +552,10 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
directories_grid.setDragSelectActive(position)
}
override fun recheckPinnedFolders() {
gotDirectories(movePinnedDirectoriesToFront(mDirs), true)
}
private fun checkWhatsNewDialog() {
arrayListOf<Release>().apply {
add(Release(46, R.string.release_46))

View File

@ -221,7 +221,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
config.removePinnedFolders(getSelectedPaths())
pinnedFolders = config.pinnedFolders
listener?.refreshItems()
listener?.recheckPinnedFolders()
notifyDataSetChanged()
actMode?.finish()
}
@ -462,5 +462,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
fun tryDeleteFolders(folders: ArrayList<File>)
fun itemLongClicked(position: Int)
fun recheckPinnedFolders()
}
}

View File

@ -75,7 +75,11 @@ fun Context.movePinnedDirectoriesToFront(dirs: ArrayList<Directory>): ArrayList<
val foundFolders = ArrayList<Directory>()
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