Sort and display explorer elements only after recursive mapping

This commit is contained in:
Matéo Duparc 2021-06-13 19:27:03 +02:00
parent 652fc98ba4
commit 401449d40a
Signed by untrusted user: hardcoresushi
GPG Key ID: 007F84120107191E
2 changed files with 10 additions and 8 deletions

View File

@ -21,7 +21,7 @@ import java.util.*
class ExplorerElementAdapter(private val context: Context) : BaseAdapter() {
private val dateFormat: DateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.getDefault())
private lateinit var explorerElements: List<ExplorerElement>
private var explorerElements = listOf<ExplorerElement>()
private val inflater: LayoutInflater = LayoutInflater.from(context)
val selectedItems: MutableList<Int> = ArrayList()
private val themeColor = ThemeColor.getThemeColor(context)
@ -113,7 +113,7 @@ class ExplorerElementAdapter(private val context: Context) : BaseAdapter() {
}
fun setExplorerElements(explorer_elements: List<ExplorerElement>) {
unSelectAll()
this.explorerElements = explorer_elements
unSelectAll()
}
}

View File

@ -216,11 +216,6 @@ open class BaseExplorerActivity : BaseActivity() {
protected fun setCurrentPath(path: String) {
explorerElements = gocryptfsVolume.listDir(path)
textDirEmpty.visibility = if (explorerElements.size == 0) View.VISIBLE else View.INVISIBLE
sortExplorerElements()
if (path.isNotEmpty()) { //not root
explorerElements.add(0, ExplorerElement("..", (-1).toShort(), -1, -1, currentDirectoryPath))
}
explorerAdapter.setExplorerElements(explorerElements)
currentDirectoryPath = path
currentPathText.text = getString(R.string.location, currentDirectoryPath)
Thread{
@ -241,7 +236,14 @@ open class BaseExplorerActivity : BaseActivity() {
}
runOnUiThread {
totalSizeText.text = getString(R.string.total_size, PathUtils.formatSize(totalSize))
explorerAdapter.notifyDataSetChanged()
sortExplorerElements()
if (path.isNotEmpty()) { //not root
explorerElements.add(
0,
ExplorerElement("..", (-1).toShort(), -1, -1, currentDirectoryPath)
)
}
explorerAdapter.setExplorerElements(explorerElements)
}
}.start()
}