Search in sources :

Example 6 with TreeNode

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

the class AndroidTreeView method restoreNodeState.

private void restoreNodeState(TreeNode node, Set<String> openNodes) {
    for (TreeNode n : node.getChildren()) {
        if (openNodes.contains(n.getPath())) {
            expandNode(n);
            restoreNodeState(n, openNodes);
        }
    }
}
Also used : TreeNode(com.unnamed.b.atv.model.TreeNode)

Example 7 with TreeNode

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

the class AndroidTreeView method collapseNode.

private void collapseNode(TreeNode node, final boolean includeSubnodes) {
    node.setExpanded(false);
    TreeNode.BaseNodeViewHolder nodeViewHolder = getViewHolderForNode(node);
    if (mUseDefaultAnimation) {
        collapse(nodeViewHolder.getNodeItemsView());
    } else {
        nodeViewHolder.getNodeItemsView().setVisibility(View.GONE);
    }
    nodeViewHolder.toggle(false);
    if (includeSubnodes) {
        for (TreeNode n : node.getChildren()) {
            collapseNode(n, includeSubnodes);
        }
    }
}
Also used : TreeNode(com.unnamed.b.atv.model.TreeNode)

Example 8 with TreeNode

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

the class AndroidTreeView method addNode.

private void addNode(ViewGroup container, final TreeNode n) {
    final TreeNode.BaseNodeViewHolder viewHolder = getViewHolderForNode(n);
    final View nodeView = viewHolder.getView();
    container.addView(nodeView);
    if (mSelectionModeEnabled) {
        viewHolder.toggleSelectionMode(mSelectionModeEnabled);
    }
    nodeView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (n.getClickListener() != null) {
                n.getClickListener().onClick(n, n.getValue());
            } else if (nodeClickListener != null) {
                nodeClickListener.onClick(n, n.getValue());
            }
            if (enableAutoToggle) {
                toggleNode(n);
            }
        }
    });
    nodeView.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View view) {
            if (n.getLongClickListener() != null) {
                return n.getLongClickListener().onLongClick(n, n.getValue());
            } else if (nodeLongClickListener != null) {
                return nodeLongClickListener.onLongClick(n, n.getValue());
            }
            if (enableAutoToggle) {
                toggleNode(n);
            }
            return false;
        }
    });
}
Also used : TreeNode(com.unnamed.b.atv.model.TreeNode) ScrollView(android.widget.ScrollView) View(android.view.View)

Example 9 with TreeNode

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

the class CustomViewHolderFragment method addProfileData.

private void addProfileData(TreeNode profile) {
    TreeNode socialNetworks = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_people, "Social")).setViewHolder(new HeaderHolder(getActivity()));
    TreeNode places = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_place, "Places")).setViewHolder(new HeaderHolder(getActivity()));
    TreeNode facebook = new TreeNode(new SocialViewHolder.SocialItem(R.string.ic_post_facebook)).setViewHolder(new SocialViewHolder(getActivity()));
    TreeNode linkedin = new TreeNode(new SocialViewHolder.SocialItem(R.string.ic_post_linkedin)).setViewHolder(new SocialViewHolder(getActivity()));
    TreeNode google = new TreeNode(new SocialViewHolder.SocialItem(R.string.ic_post_gplus)).setViewHolder(new SocialViewHolder(getActivity()));
    TreeNode twitter = new TreeNode(new SocialViewHolder.SocialItem(R.string.ic_post_twitter)).setViewHolder(new SocialViewHolder(getActivity()));
    TreeNode lake = new TreeNode(new PlaceHolderHolder.PlaceItem("A rose garden")).setViewHolder(new PlaceHolderHolder(getActivity()));
    TreeNode mountains = new TreeNode(new PlaceHolderHolder.PlaceItem("The white house")).setViewHolder(new PlaceHolderHolder(getActivity()));
    places.addChildren(lake, mountains);
    socialNetworks.addChildren(facebook, google, twitter, linkedin);
    profile.addChildren(socialNetworks, places);
}
Also used : HeaderHolder(com.unnamed.b.atv.sample.holder.HeaderHolder) TreeNode(com.unnamed.b.atv.model.TreeNode) PlaceHolderHolder(com.unnamed.b.atv.sample.holder.PlaceHolderHolder) SocialViewHolder(com.unnamed.b.atv.sample.holder.SocialViewHolder)

Example 10 with TreeNode

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

the class FolderStructureFragment method fillDownloadsFolder.

private void fillDownloadsFolder(TreeNode node) {
    TreeNode downloads = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_folder, "Downloads" + (counter++)));
    node.addChild(downloads);
    if (counter < 5) {
        fillDownloadsFolder(downloads);
    }
}
Also used : TreeNode(com.unnamed.b.atv.model.TreeNode) IconTreeItemHolder(com.unnamed.b.atv.sample.holder.IconTreeItemHolder)

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