Skip to content

Commit 599ea09

Browse files
committed
optimize the way of fetching all selected items
1 parent 9aaf8fb commit 599ea09

File tree

1 file changed

+1
-9
lines changed
  • app/src/main/kotlin/com/simplemobiletools/filemanager/adapters

1 file changed

+1
-9
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -513,15 +513,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
513513

514514
private fun getFirstSelectedItemPath() = getSelectedFileDirItems().first().path
515515

516-
private fun getSelectedFileDirItems(): ArrayList<FileDirItem> {
517-
val selectedFileDirItems = ArrayList<FileDirItem>(selectedKeys.size)
518-
selectedKeys.forEach {
519-
getItemWithKey(it)?.apply {
520-
selectedFileDirItems.add(this)
521-
}
522-
}
523-
return selectedFileDirItems
524-
}
516+
private fun getSelectedFileDirItems() = fileDirItems.filter { selectedKeys.contains(it.path.hashCode()) } as ArrayList<FileDirItem>
525517

526518
fun updateItems(newItems: ArrayList<FileDirItem>, highlightText: String = "") {
527519
if (newItems.hashCode() != currentItemsHash) {

0 commit comments

Comments
 (0)