mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix(treeview): use sort only when necessary when adding a child (#1456)
This commit is contained in:
@@ -174,7 +174,7 @@ class FileTreeFragment : BottomSheetDialogFragment(), TreeNodeClickListener,
|
||||
for (file in files) {
|
||||
val node = TreeNode(file)
|
||||
node.viewHolder = FileTreeViewHolder(context)
|
||||
parent.addChild(node)
|
||||
parent.addChild(node, false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ class FileTreeFragment : BottomSheetDialogFragment(), TreeNodeClickListener,
|
||||
|
||||
val projectRoot = TreeNode.root(projectDir)
|
||||
projectRoot.viewHolder = FileTreeViewHolder(context)
|
||||
rootNode.addChild(projectRoot)
|
||||
rootNode.addChild(projectRoot, false)
|
||||
|
||||
binding!!.horizontalCroll.visibility = View.GONE
|
||||
binding!!.horizontalCroll.visibility = View.VISIBLE
|
||||
|
||||
@@ -54,7 +54,7 @@ public class FileTreeCallable implements Callable<Boolean> {
|
||||
for (File file : files) {
|
||||
TreeNode node = new TreeNode(file);
|
||||
node.setViewHolder(new FileTreeViewHolder(ctx));
|
||||
parent.addChild(node);
|
||||
parent.addChild(node, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,11 +54,18 @@ public class TreeNode {
|
||||
}
|
||||
|
||||
public TreeNode addChild(TreeNode childNode) {
|
||||
return addChild(childNode, true);
|
||||
}
|
||||
|
||||
public TreeNode addChild(TreeNode childNode, boolean sort) {
|
||||
childNode.mParent = this;
|
||||
childNode.mId = generateId();
|
||||
children.add(childNode);
|
||||
Collections.sort(children, new SortFileName());
|
||||
Collections.sort(children, new SortFolder());
|
||||
|
||||
if (sort) {
|
||||
Collections.sort(children, new SortFileName());
|
||||
Collections.sort(children, new SortFolder());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user