Search in sources :

Example 21 with TreeNode

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);
        }
    }
}
Also used : TreeNode(com.unnamed.b.atv.model.TreeNode)

Example 22 with TreeNode

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;
}
Also used : PrintView(com.github.johnkil.print.PrintView) TreeNode(com.unnamed.b.atv.model.TreeNode) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) PrintView(com.github.johnkil.print.PrintView) View(android.view.View)

Aggregations

TreeNode (com.unnamed.b.atv.model.TreeNode)22 View (android.view.View)10 ViewGroup (android.view.ViewGroup)6 AndroidTreeView (com.unnamed.b.atv.view.AndroidTreeView)5 TextView (android.widget.TextView)4 LayoutInflater (android.view.LayoutInflater)3 PrintView (com.github.johnkil.print.PrintView)3 IconTreeItemHolder (com.unnamed.b.atv.sample.holder.IconTreeItemHolder)3 SelectableHeaderHolder (com.unnamed.b.atv.sample.holder.SelectableHeaderHolder)3 CompoundButton (android.widget.CompoundButton)2 ScrollView (android.widget.ScrollView)2 ProfileHolder (com.unnamed.b.atv.sample.holder.ProfileHolder)2 Context (android.content.Context)1 ContextThemeWrapper (android.view.ContextThemeWrapper)1 LinearLayout (android.widget.LinearLayout)1 ArrowExpandSelectableHeaderHolder (com.unnamed.b.atv.sample.holder.ArrowExpandSelectableHeaderHolder)1 HeaderHolder (com.unnamed.b.atv.sample.holder.HeaderHolder)1 PlaceHolderHolder (com.unnamed.b.atv.sample.holder.PlaceHolderHolder)1 SelectableItemHolder (com.unnamed.b.atv.sample.holder.SelectableItemHolder)1 SocialViewHolder (com.unnamed.b.atv.sample.holder.SocialViewHolder)1