Search in sources :

Example 16 with TreeNode

use of com.unnamed.b.atv.model.TreeNode in project AndroidTreeView by bmelnychuk.

the class AndroidTreeView method selectNode.

private void selectNode(TreeNode parent, boolean selected, boolean skipCollapsed) {
    parent.setSelected(selected);
    toogleSelectionForNode(parent, true);
    boolean toContinue = skipCollapsed ? parent.isExpanded() : true;
    if (toContinue) {
        for (TreeNode node : parent.getChildren()) {
            selectNode(node, selected, skipCollapsed);
        }
    }
}
Also used : TreeNode(com.unnamed.b.atv.model.TreeNode)

Example 17 with TreeNode

use of com.unnamed.b.atv.model.TreeNode in project AndroidTreeView by bmelnychuk.

the class AndroidTreeView method expandNode.

private void expandNode(final TreeNode node, boolean includeSubnodes) {
    node.setExpanded(true);
    final TreeNode.BaseNodeViewHolder parentViewHolder = getViewHolderForNode(node);
    parentViewHolder.getNodeItemsView().removeAllViews();
    parentViewHolder.toggle(true);
    for (final TreeNode n : node.getChildren()) {
        addNode(parentViewHolder.getNodeItemsView(), n);
        if (n.isExpanded() || includeSubnodes) {
            expandNode(n, includeSubnodes);
        }
    }
    if (mUseDefaultAnimation) {
        expand(parentViewHolder.getNodeItemsView());
    } else {
        parentViewHolder.getNodeItemsView().setVisibility(View.VISIBLE);
    }
}
Also used : TreeNode(com.unnamed.b.atv.model.TreeNode)

Example 18 with TreeNode

use of com.unnamed.b.atv.model.TreeNode in project AndroidTreeView by bmelnychuk.

the class AndroidTreeView method getSelectedValues.

public <E> List<E> getSelectedValues(Class<E> clazz) {
    List<E> result = new ArrayList<>();
    List<TreeNode> selected = getSelected();
    for (TreeNode n : selected) {
        Object value = n.getValue();
        if (value != null && value.getClass().equals(clazz)) {
            result.add((E) value);
        }
    }
    return result;
}
Also used : TreeNode(com.unnamed.b.atv.model.TreeNode) ArrayList(java.util.ArrayList)

Example 19 with TreeNode

use of com.unnamed.b.atv.model.TreeNode in project AndroidTreeView by bmelnychuk.

the class AndroidTreeView method getView.

public View getView(int style) {
    final ViewGroup view;
    if (style > 0) {
        ContextThemeWrapper newContext = new ContextThemeWrapper(mContext, style);
        view = use2dScroll ? new TwoDScrollView(newContext) : new ScrollView(newContext);
    } else {
        view = use2dScroll ? new TwoDScrollView(mContext) : new ScrollView(mContext);
    }
    Context containerContext = mContext;
    if (containerStyle != 0 && applyForRoot) {
        containerContext = new ContextThemeWrapper(mContext, containerStyle);
    }
    final LinearLayout viewTreeItems = new LinearLayout(containerContext, null, containerStyle);
    viewTreeItems.setId(R.id.tree_items);
    viewTreeItems.setOrientation(LinearLayout.VERTICAL);
    view.addView(viewTreeItems);
    mRoot.setViewHolder(new TreeNode.BaseNodeViewHolder(mContext) {

        @Override
        public View createNodeView(TreeNode node, Object value) {
            return null;
        }

        @Override
        public ViewGroup getNodeItemsView() {
            return viewTreeItems;
        }
    });
    expandNode(mRoot, false);
    return view;
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.view.ContextThemeWrapper) ScrollView(android.widget.ScrollView) ViewGroup(android.view.ViewGroup) TreeNode(com.unnamed.b.atv.model.TreeNode) ScrollView(android.widget.ScrollView) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 20 with TreeNode

use of com.unnamed.b.atv.model.TreeNode in project AndroidTreeView by bmelnychuk.

the class AndroidTreeView method getSaveState.

private void getSaveState(TreeNode root, StringBuilder sBuilder) {
    for (TreeNode node : root.getChildren()) {
        if (node.isExpanded()) {
            sBuilder.append(node.getPath());
            sBuilder.append(NODES_PATH_SEPARATOR);
            getSaveState(node, sBuilder);
        }
    }
}
Also used : TreeNode(com.unnamed.b.atv.model.TreeNode)

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