update directories instantly after renaming, do not refetch everything
This commit is contained in:
parent
f1fe2028d5
commit
0271af9c55
3 changed files with 22 additions and 6 deletions
|
@ -36,7 +36,6 @@ import com.simplemobiletools.gallery.helpers.*
|
||||||
import com.simplemobiletools.gallery.models.Directory
|
import com.simplemobiletools.gallery.models.Directory
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
private val PICK_MEDIA = 2
|
private val PICK_MEDIA = 2
|
||||||
|
@ -682,6 +681,10 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
gotDirectories(movePinnedDirectoriesToFront(mDirs), true)
|
gotDirectories(movePinnedDirectoriesToFront(mDirs), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun updateDirectories(directories: ArrayList<Directory>) {
|
||||||
|
gotDirectories(directories, true)
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkWhatsNewDialog() {
|
private fun checkWhatsNewDialog() {
|
||||||
arrayListOf<Release>().apply {
|
arrayListOf<Release>().apply {
|
||||||
add(Release(46, R.string.release_46))
|
add(Release(46, R.string.release_46))
|
||||||
|
|
|
@ -27,6 +27,7 @@ import com.simplemobiletools.gallery.models.Directory
|
||||||
import kotlinx.android.synthetic.main.directory_item_list.view.*
|
import kotlinx.android.synthetic.main.directory_item_list.view.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList<Directory>, val listener: DirOperationsListener?, recyclerView: MyRecyclerView,
|
class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList<Directory>, val listener: DirOperationsListener?, recyclerView: MyRecyclerView,
|
||||||
val isPickIntent: Boolean, fastScroller: FastScroller? = null, itemClick: (Any) -> Unit) :
|
val isPickIntent: Boolean, fastScroller: FastScroller? = null, itemClick: (Any) -> Unit) :
|
||||||
|
@ -153,8 +154,8 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList<Direc
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renameDir() {
|
private fun renameDir() {
|
||||||
val path = dirs[selectedPositions.first()].path
|
val sourcePath = dirs[selectedPositions.first()].path
|
||||||
val dir = File(path)
|
val dir = File(sourcePath)
|
||||||
if (activity.isAStorageRootFolder(dir.absolutePath)) {
|
if (activity.isAStorageRootFolder(dir.absolutePath)) {
|
||||||
activity.toast(R.string.rename_folder_root)
|
activity.toast(R.string.rename_folder_root)
|
||||||
return
|
return
|
||||||
|
@ -162,8 +163,18 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList<Direc
|
||||||
|
|
||||||
RenameItemDialog(activity, dir.absolutePath) {
|
RenameItemDialog(activity, dir.absolutePath) {
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
listener?.refreshItems()
|
if (selectedPositions.isEmpty()) {
|
||||||
finishActMode()
|
return@runOnUiThread
|
||||||
|
}
|
||||||
|
|
||||||
|
dirs[selectedPositions.first()].apply {
|
||||||
|
path = it
|
||||||
|
name = it.getFilenameFromPath()
|
||||||
|
|
||||||
|
val tmbFile = tmb.getFilenameFromPath()
|
||||||
|
tmb = File(it, tmbFile).absolutePath
|
||||||
|
}
|
||||||
|
listener?.updateDirectories(dirs.toList() as ArrayList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,5 +397,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList<Direc
|
||||||
fun deleteFolders(folders: ArrayList<File>)
|
fun deleteFolders(folders: ArrayList<File>)
|
||||||
|
|
||||||
fun recheckPinnedFolders()
|
fun recheckPinnedFolders()
|
||||||
|
|
||||||
|
fun updateDirectories(directories: ArrayList<Directory>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.simplemobiletools.commons.extensions.formatSize
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import java.io.Serializable
|
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<Directory> {
|
val size: Long, val isOnSDCard: Boolean) : Serializable, Comparable<Directory> {
|
||||||
companion object {
|
companion object {
|
||||||
private val serialVersionUID = -6553345863555455L
|
private val serialVersionUID = -6553345863555455L
|
||||||
|
|
Loading…
Reference in a new issue