Skip to content

Commit

Permalink
fix the bug about adapter.ifCollapseChildWhileCollapseParent(true)
Browse files Browse the repository at this point in the history
  • Loading branch information
TellH committed Jan 19, 2017
1 parent 3f63ba8 commit 16632f9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void initData() {
rv.setLayoutManager(new LinearLayoutManager(this));
adapter = new TreeViewAdapter(nodes, Arrays.asList(new FileNodeBinder(), new DirectoryNodeBinder()));
// whether collapse child nodes when their parent node was close.
adapter.ifCollapseChildWhileCollapseParent(true);
// adapter.ifCollapseChildWhileCollapseParent(true);
adapter.setOnTreeNodeListener(new TreeViewAdapter.OnTreeNodeListener() {
@Override
public boolean onClick(TreeNode node, RecyclerView.ViewHolder holder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ public boolean toggle() {
return isExpand;
}

public void collapse() {
if (!isExpand)
isExpand = false;
}

public void expand() {
if (isExpand)
isExpand = true;
}

public boolean isExpand() {
return isExpand;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ private int addChildNodes(TreeNode pNode, int startIndex) {
addChildCount += addChildNodes(treeNode, startIndex + addChildCount);
}
}
pNode.toggle();
if (!pNode.isExpand())
pNode.toggle();
return addChildCount;
}

Expand Down

0 comments on commit 16632f9

Please sign in to comment.