use of com.unnamed.b.atv.model.TreeNode in project AndroidTreeView by bmelnychuk.
the class AndroidTreeView method removeNode.
public void removeNode(TreeNode node) {
if (node.getParent() != null) {
TreeNode parent = node.getParent();
int index = parent.deleteChild(node);
if (parent.isExpanded() && index >= 0) {
final TreeNode.BaseNodeViewHolder parentViewHolder = getViewHolderForNode(parent);
parentViewHolder.getNodeItemsView().removeViewAt(index);
}
}
}
use of com.unnamed.b.atv.model.TreeNode in project AndroidTreeView by bmelnychuk.
the class IconTreeItemHolder method createNodeView.
@Override
public View createNodeView(final TreeNode node, IconTreeItem value) {
final LayoutInflater inflater = LayoutInflater.from(context);
final View view = inflater.inflate(R.layout.layout_icon_node, null, false);
tvValue = (TextView) view.findViewById(R.id.node_value);
tvValue.setText(value.text);
final PrintView iconView = (PrintView) view.findViewById(R.id.icon);
iconView.setIconText(context.getResources().getString(value.icon));
arrowView = (PrintView) view.findViewById(R.id.arrow_icon);
view.findViewById(R.id.btn_addFolder).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TreeNode newFolder = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_folder, "New Folder"));
getTreeView().addNode(node, newFolder);
}
});
view.findViewById(R.id.btn_delete).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getTreeView().removeNode(node);
}
});
// if My computer
if (node.getLevel() == 1) {
view.findViewById(R.id.btn_delete).setVisibility(View.GONE);
}
return view;
}
Aggregations