Skip to content

Latest commit

 

History

History
121 lines (81 loc) · 2.22 KB

treeview-adapter.md

File metadata and controls

121 lines (81 loc) · 2.22 KB

TreeView Adapter

TreeView come with it own Adapter to easily provide tree view features on any RecyclerView.

TreeViewAdapter class can be created with 2 options, first with ViewHoldersFactory and it will use the default TreeNodeManager

TreeViewAdapter adapter = new TreeViewAdapter(factory);

The other option is used if you have a custom TreeNodeManager.

TreeViewAdapter adapter = new TreeViewAdapter(factory, customTreeNodeManager);

Update the list of tree nodes

public void updateTreeNodes(List<TreeNode> treeNodes)

Delete all tree nodes

public void clearTreeNodes()

Collapsing node and all of his children

public void collapseNode(TreeNode node)

Expanding node and all of his children

public void expandNode(TreeNode node)

Collapsing full node branches

public void collapseNodeBranch(TreeNode node)

Expanding node full branches

public void expandNodeBranch(TreeNode node)

Expanding one node branch to until specific level

public void expandNodeToLevel(TreeNode node, int level)

Expanding all tree nodes branches to until specific level

public void expandNodesAtLevel(int level)

Collapsing all nodes in the tree with their children

public void collapseAll()

Expanding all nodes in the tree with their children

public void expandAll()

Set the current visible tree nodes and notify all data changed

public void setTreeNodes(List<TreeNode> treeNodes)

Get the Current visible Tree nodes

public List<TreeNode> getTreeNodes()

Get the current selected tree node, null of no tree node selected

public TreeNode getSelectedNode()

Register a callback to be invoked when this TreeNode is clicked

public void setTreeNodeClickListener(OnTreeNodeClickListener listener)

or using Lambda

treeViewAdapter.setTreeNodeClickListener((treeNode, nodeView) -> {
    
});

Register a callback to be invoked when this TreeNode is clicked and held

public void setTreeNodeLongClickListener(OnTreeNodeLongClickListener listener)

or using Lambda

treeViewAdapter.setTreeNodeLongClickListener((treeNode, nodeView) -> {
    return true;
});