use of com.unnamed.b.atv.view.AndroidTreeView 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.view.AndroidTreeView 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.view.AndroidTreeView 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.view.AndroidTreeView in project AndroidTreeView by bmelnychuk.
the class TwoDScrollingArrowExpandFragment 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 ArrowExpandSelectableHeaderHolder(getActivity()));
TreeNode s2 = new TreeNode(new IconTreeItemHolder.IconTreeItem(R.string.ic_folder, "Another folder with very long name")).setViewHolder(new ArrowExpandSelectableHeaderHolder(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);
tView.setDefaultNodeClickListener(TwoDScrollingArrowExpandFragment.this);
tView.setDefaultViewHolder(ArrowExpandSelectableHeaderHolder.class);
containerView.addView(tView.getView());
tView.setUseAutoToggle(false);
tView.expandAll();
if (savedInstanceState != null) {
String state = savedInstanceState.getString("tState");
if (!TextUtils.isEmpty(state)) {
tView.restoreState(state);
}
}
return rootView;
}
use of com.unnamed.b.atv.view.AndroidTreeView 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