From 0271af9c552b7c93b2cda150f753fb65e76cfc09 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 8 Apr 2018 23:14:25 +0200 Subject: [PATCH] update directories instantly after renaming, do not refetch everything --- .../gallery/activities/MainActivity.kt | 5 ++++- .../gallery/adapters/DirectoryAdapter.kt | 21 +++++++++++++++---- .../gallery/models/Directory.kt | 2 +- 3 files changed, 22 insertions(+), 6 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 c47741bab..c26f33a34 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -36,7 +36,6 @@ import com.simplemobiletools.gallery.helpers.* import com.simplemobiletools.gallery.models.Directory import kotlinx.android.synthetic.main.activity_main.* import java.io.* -import java.util.* class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private val PICK_MEDIA = 2 @@ -682,6 +681,10 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { gotDirectories(movePinnedDirectoriesToFront(mDirs), true) } + override fun updateDirectories(directories: ArrayList) { + gotDirectories(directories, 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 cf0e26157..6fa302bf9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -27,6 +27,7 @@ import com.simplemobiletools.gallery.models.Directory import kotlinx.android.synthetic.main.directory_item_list.view.* import java.io.File import java.util.* +import kotlin.collections.ArrayList class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList, val listener: DirOperationsListener?, recyclerView: MyRecyclerView, val isPickIntent: Boolean, fastScroller: FastScroller? = null, itemClick: (Any) -> Unit) : @@ -153,8 +154,8 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList) fun recheckPinnedFolders() + + fun updateDirectories(directories: ArrayList) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt index a3a54fb5a..3bb84637e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt @@ -5,7 +5,7 @@ import com.simplemobiletools.commons.extensions.formatSize import com.simplemobiletools.commons.helpers.* import java.io.Serializable -data class Directory(val path: String, val tmb: String, val name: String, var mediaCnt: Int, val modified: Long, val taken: Long, +data class Directory(var path: String, var tmb: String, var name: String, var mediaCnt: Int, val modified: Long, val taken: Long, val size: Long, val isOnSDCard: Boolean) : Serializable, Comparable { companion object { private val serialVersionUID = -6553345863555455L