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);
}
}
}
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);
}
}
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;
}
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;
}
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);
}
}
}
Aggregations