diff --git a/core/app/src/main/java/com/itsaky/androidide/fragments/sidebar/FileTreeFragment.kt b/core/app/src/main/java/com/itsaky/androidide/fragments/sidebar/FileTreeFragment.kt index 221254309f..54828cc909 100755 --- a/core/app/src/main/java/com/itsaky/androidide/fragments/sidebar/FileTreeFragment.kt +++ b/core/app/src/main/java/com/itsaky/androidide/fragments/sidebar/FileTreeFragment.kt @@ -169,8 +169,8 @@ class FileTreeFragment : BottomSheetDialogFragment(), TreeNodeClickListener, } private fun listFilesForNode(files: Array, parent: TreeNode) { - Arrays.sort(files, SortFileName()) - Arrays.sort(files, SortFolder()) + Arrays.sort(files, SORT_FILE_NAME) + Arrays.sort(files, SORT_FOLDER) for (file in files) { val node = TreeNode(file) node.viewHolder = FileTreeViewHolder(context) @@ -278,6 +278,9 @@ class FileTreeFragment : BottomSheetDialogFragment(), TreeNodeClickListener, } companion object { + + private val SORT_FILE_NAME = SortFileName() + private val SORT_FOLDER = SortFolder() // Should be same as defined in layout/activity_editor.xml const val TAG = "editor.fileTree" diff --git a/utilities/treeview/src/main/java/com/unnamed/b/atv/model/TreeNode.java b/utilities/treeview/src/main/java/com/unnamed/b/atv/model/TreeNode.java index 3dbfe000b6..917839e05d 100755 --- a/utilities/treeview/src/main/java/com/unnamed/b/atv/model/TreeNode.java +++ b/utilities/treeview/src/main/java/com/unnamed/b/atv/model/TreeNode.java @@ -18,6 +18,9 @@ /** Created by Bogdan Melnychuk on 2/10/15. */ public class TreeNode { + private static final SortFileName SORT_FILE_NAME = new SortFileName(); + private static final SortFolder SORT_FOLDER = new SortFolder(); + public static final String NODES_ID_SEPARATOR = ":"; private final List children; private int mId; @@ -63,8 +66,8 @@ public TreeNode addChild(TreeNode childNode, boolean sort) { children.add(childNode); if (sort) { - Collections.sort(children, new SortFileName()); - Collections.sort(children, new SortFolder()); + Collections.sort(children, SORT_FILE_NAME); + Collections.sort(children, SORT_FOLDER); } return this; }