sort the hidden folders by .nomedia last modified + fix threading
This commit is contained in:
parent
865db7099f
commit
cd03b455dc
|
@ -21,17 +21,20 @@ class HiddenFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateFolders() {
|
private fun updateFolders() {
|
||||||
val folders = getNoMediaFolders()
|
getNoMediaFolders {
|
||||||
|
runOnUiThread {
|
||||||
manage_folders_placeholder.apply {
|
manage_folders_placeholder.apply {
|
||||||
text = getString(R.string.hidden_folders_placeholder)
|
text = getString(R.string.hidden_folders_placeholder)
|
||||||
beVisibleIf(folders.isEmpty())
|
beVisibleIf(it.isEmpty())
|
||||||
setTextColor(config.textColor)
|
setTextColor(config.textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
val adapter = ManageHiddenFoldersAdapter(this, folders, this, manage_folders_list) {}
|
val adapter = ManageHiddenFoldersAdapter(this, it, this, manage_folders_list) {}
|
||||||
adapter.setupDragListener(true)
|
adapter.setupDragListener(true)
|
||||||
manage_folders_list.adapter = adapter
|
manage_folders_list.adapter = adapter
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
menuInflater.inflate(R.menu.menu_add_folder, menu)
|
menuInflater.inflate(R.menu.menu_add_folder, menu)
|
||||||
|
|
|
@ -79,14 +79,15 @@ fun Context.getSortedDirectories(source: ArrayList<Directory>): ArrayList<Direct
|
||||||
return movePinnedDirectoriesToFront(dirs)
|
return movePinnedDirectoriesToFront(dirs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.getNoMediaFolders(): ArrayList<String> {
|
fun Context.getNoMediaFolders(callback: (folders: ArrayList<String>) -> Unit) {
|
||||||
|
Thread {
|
||||||
val folders = ArrayList<String>()
|
val folders = ArrayList<String>()
|
||||||
|
|
||||||
val uri = MediaStore.Files.getContentUri("external")
|
val uri = MediaStore.Files.getContentUri("external")
|
||||||
val projection = arrayOf(MediaStore.Files.FileColumns.DATA)
|
val projection = arrayOf(MediaStore.Files.FileColumns.DATA)
|
||||||
val selection = "${MediaStore.Files.FileColumns.MEDIA_TYPE} = ? AND ${MediaStore.Files.FileColumns.TITLE} LIKE ?"
|
val selection = "${MediaStore.Files.FileColumns.MEDIA_TYPE} = ? AND ${MediaStore.Files.FileColumns.TITLE} LIKE ?"
|
||||||
val selectionArgs = arrayOf(MediaStore.Files.FileColumns.MEDIA_TYPE_NONE.toString(), "%$NOMEDIA%")
|
val selectionArgs = arrayOf(MediaStore.Files.FileColumns.MEDIA_TYPE_NONE.toString(), "%$NOMEDIA%")
|
||||||
val sortOrder = MediaStore.Files.FileColumns.DATA
|
val sortOrder = "${MediaStore.Files.FileColumns.DATE_MODIFIED} DESC"
|
||||||
|
|
||||||
var cursor: Cursor? = null
|
var cursor: Cursor? = null
|
||||||
|
|
||||||
|
@ -105,5 +106,6 @@ fun Context.getNoMediaFolders(): ArrayList<String> {
|
||||||
cursor?.close()
|
cursor?.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
return folders
|
callback(folders)
|
||||||
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue