use of com.unnamed.b.atv.sample.holder.SelectableHeaderHolder 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.sample.holder.SelectableHeaderHolder in project AndroidTreeView by bmelnychuk.
the class TwoDScrollingFragment method fillFolder.
private void fillFolder(TreeNode folder) {
TreeNode currentNode = folder;
for (int i = 0; i < 10; i++) {
TreeNode file = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_folder, NAME)).setViewHolder(new SelectableHeaderHolder(getActivity()));
currentNode.addChild(file);
currentNode = file;
}
}
use of com.unnamed.b.atv.sample.holder.SelectableHeaderHolder in project AndroidTreeView by bmelnychuk.
the class TwoDScrollingFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_selectable_nodes, null, false);
rootView.findViewById(R.id.status).setVisibility(View.GONE);
ViewGroup containerView = (ViewGroup) rootView.findViewById(R.id.container);
TreeNode root = TreeNode.root();
TreeNode s1 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_folder, "Folder with very long name ")).setViewHolder(new SelectableHeaderHolder(getActivity()));
TreeNode s2 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_folder, "Another folder with very long name")).setViewHolder(new SelectableHeaderHolder(getActivity()));
fillFolder(s1);
fillFolder(s2);
root.addChildren(s1, s2);
tView = new AndroidTreeView(getActivity(), root);
tView.setDefaultAnimation(true);
tView.setUse2dScroll(true);
tView.setDefaultContainerStyle(R.style.TreeNodeStyleCustom);
containerView.addView(tView.getView());
tView.expandAll();
if (savedInstanceState != null) {
String state = savedInstanceState.getString("tState");
if (!TextUtils.isEmpty(state)) {
tView.restoreState(state);
}
}
return rootView;
}
Aggregations