use of com.unnamed.b.atv.model.TreeNode in project AndroidTreeView by bmelnychuk.
the class CustomViewHolderFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_default, null, false);
final ViewGroup containerView = (ViewGroup) rootView.findViewById(R.id.container);
rootView.findViewById(R.id.status_bar).setVisibility(View.GONE);
final TreeNode root = TreeNode.root();
TreeNode myProfile = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_person, "My Profile")).setViewHolder(new ProfileHolder(getActivity()));
TreeNode bruce = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_person, "Bruce Wayne")).setViewHolder(new ProfileHolder(getActivity()));
TreeNode clark = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_person, "Clark Kent")).setViewHolder(new ProfileHolder(getActivity()));
TreeNode barry = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_person, "Barry Allen")).setViewHolder(new ProfileHolder(getActivity()));
addProfileData(myProfile);
addProfileData(clark);
addProfileData(bruce);
addProfileData(barry);
root.addChildren(myProfile, bruce, barry, clark);
tView = new AndroidTreeView(getActivity(), root);
tView.setDefaultAnimation(true);
tView.setDefaultContainerStyle(R.style.TreeNodeStyleDivided, true);
containerView.addView(tView.getView());
if (savedInstanceState != null) {
String state = savedInstanceState.getString("tState");
if (!TextUtils.isEmpty(state)) {
tView.restoreState(state);
}
}
return rootView;
}
use of com.unnamed.b.atv.model.TreeNode in project AndroidTreeView by bmelnychuk.
the class FolderStructureFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_default, null, false);
ViewGroup containerView = (ViewGroup) rootView.findViewById(R.id.container);
statusBar = (TextView) rootView.findViewById(R.id.status_bar);
TreeNode root = TreeNode.root();
TreeNode computerRoot = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_laptop, "My Computer"));
TreeNode myDocuments = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_folder, "My Documents"));
TreeNode downloads = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_folder, "Downloads"));
TreeNode file1 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_drive_file, "Folder 1"));
TreeNode file2 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_drive_file, "Folder 2"));
TreeNode file3 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_drive_file, "Folder 3"));
TreeNode file4 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_drive_file, "Folder 4"));
fillDownloadsFolder(downloads);
downloads.addChildren(file1, file2, file3, file4);
TreeNode myMedia = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_photo_library, "Photos"));
TreeNode photo1 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_photo, "Folder 1"));
TreeNode photo2 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_photo, "Folder 2"));
TreeNode photo3 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_photo, "Folder 3"));
myMedia.addChildren(photo1, photo2, photo3);
myDocuments.addChild(downloads);
computerRoot.addChildren(myDocuments, myMedia);
root.addChildren(computerRoot);
tView = new AndroidTreeView(getActivity(), root);
tView.setDefaultAnimation(true);
tView.setDefaultContainerStyle(R.style.TreeNodeStyleCustom);
tView.setDefaultViewHolder(IconTreeItemHolder.class);
tView.setDefaultNodeClickListener(nodeClickListener);
tView.setDefaultNodeLongClickListener(nodeLongClickListener);
containerView.addView(tView.getView());
if (savedInstanceState != null) {
String state = savedInstanceState.getString("tState");
if (!TextUtils.isEmpty(state)) {
tView.restoreState(state);
}
}
return rootView;
}
use of com.unnamed.b.atv.model.TreeNode in project AndroidTreeView by bmelnychuk.
the class SelectableTreeFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_selectable_nodes, null, false);
ViewGroup containerView = (ViewGroup) rootView.findViewById(R.id.container);
View selectionModeButton = rootView.findViewById(R.id.btn_toggleSelection);
selectionModeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectionModeEnabled = !selectionModeEnabled;
tView.setSelectionModeEnabled(selectionModeEnabled);
}
});
View selectAllBtn = rootView.findViewById(R.id.btn_selectAll);
selectAllBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!selectionModeEnabled) {
Toast.makeText(getActivity(), "Enable selection mode first", Toast.LENGTH_SHORT).show();
}
tView.selectAll(true);
}
});
View deselectAll = rootView.findViewById(R.id.btn_deselectAll);
deselectAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!selectionModeEnabled) {
Toast.makeText(getActivity(), "Enable selection mode first", Toast.LENGTH_SHORT).show();
}
tView.deselectAll();
}
});
View check = rootView.findViewById(R.id.btn_checkSelection);
check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!selectionModeEnabled) {
Toast.makeText(getActivity(), "Enable selection mode first", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity(), tView.getSelected().size() + " selected", Toast.LENGTH_SHORT).show();
}
}
});
TreeNode root = TreeNode.root();
TreeNode s1 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_sd_storage, "Storage1")).setViewHolder(new ProfileHolder(getActivity()));
TreeNode s2 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_sd_storage, "Storage2")).setViewHolder(new ProfileHolder(getActivity()));
s1.setSelectable(false);
s2.setSelectable(false);
TreeNode folder1 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_folder, "Folder 1")).setViewHolder(new SelectableHeaderHolder(getActivity()));
TreeNode folder2 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_folder, "Folder 2")).setViewHolder(new SelectableHeaderHolder(getActivity()));
TreeNode folder3 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_folder, "Folder 3")).setViewHolder(new SelectableHeaderHolder(getActivity()));
fillFolder(folder1);
fillFolder(folder2);
fillFolder(folder3);
s1.addChildren(folder1, folder2);
s2.addChildren(folder3);
root.addChildren(s1, s2);
tView = new AndroidTreeView(getActivity(), root);
tView.setDefaultAnimation(true);
containerView.addView(tView.getView());
if (savedInstanceState != null) {
String state = savedInstanceState.getString("tState");
if (!TextUtils.isEmpty(state)) {
tView.restoreState(state);
}
}
return rootView;
}
use of com.unnamed.b.atv.model.TreeNode in project AndroidTreeView by bmelnychuk.
the class ArrowExpandSelectableHeaderHolder method createNodeView.
@Override
public View createNodeView(final TreeNode node, IconTreeItemHolder.IconTreeItem value) {
final LayoutInflater inflater = LayoutInflater.from(context);
final View view = inflater.inflate(R.layout.layout_selectable_header, 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);
arrowView.setPadding(20, 10, 10, 10);
if (node.isLeaf()) {
arrowView.setVisibility(View.GONE);
}
arrowView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
tView.toggleNode(node);
}
});
nodeSelector = (CheckBox) view.findViewById(R.id.node_selector);
nodeSelector.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
node.setSelected(isChecked);
for (TreeNode n : node.getChildren()) {
getTreeView().selectNode(n, isChecked);
}
}
});
nodeSelector.setChecked(node.isSelected());
return view;
}
use of com.unnamed.b.atv.model.TreeNode in project AndroidTreeView by bmelnychuk.
the class SelectableHeaderHolder method createNodeView.
@Override
public View createNodeView(final TreeNode node, IconTreeItemHolder.IconTreeItem value) {
final LayoutInflater inflater = LayoutInflater.from(context);
final View view = inflater.inflate(R.layout.layout_selectable_header, 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);
if (node.isLeaf()) {
arrowView.setVisibility(View.GONE);
}
nodeSelector = (CheckBox) view.findViewById(R.id.node_selector);
nodeSelector.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
node.setSelected(isChecked);
for (TreeNode n : node.getChildren()) {
getTreeView().selectNode(n, isChecked);
}
}
});
nodeSelector.setChecked(node.isSelected());
return view;
}
Aggregations