use of com.github.pockethub.android.ui.StyledText in project PocketHub by pockethub.
the class RepositoryCodeFragment method setFolder.
private void setFolder(final FullTree tree, final Folder folder) {
this.folder = folder;
this.tree = tree;
showLoading(false);
branchView.setText(tree.branch);
if (RefUtils.isTag(tree.reference)) {
branchIconView.setText(R.string.icon_tag);
} else {
branchIconView.setText(R.string.icon_fork);
}
adapter.getWrappedAdapter().setIndented(folder.entry != null);
if (folder.entry != null) {
int textLightColor = getResources().getColor(R.color.text_light);
final String[] segments = folder.entry.path().split("/");
StyledText text = new StyledText();
for (int i = 0; i < segments.length - 1; i++) {
final int index = i;
text.url(segments[i], new OnClickListener() {
@Override
public void onClick(View v) {
Folder clicked = folder;
for (int i = index; i < segments.length - 1; i++) {
clicked = clicked.parent;
if (clicked == null) {
return;
}
}
setFolder(tree, clicked);
}
}).append(' ').foreground('/', textLightColor).append(' ');
}
text.bold(segments[segments.length - 1]);
pathView.setText(text);
if (!pathShowing) {
adapter.addHeader(pathHeaderView);
pathShowing = true;
}
} else if (pathShowing) {
adapter.removeHeader(pathHeaderView);
pathShowing = false;
}
adapter.getWrappedAdapter().setItems(folder);
listView.setSelection(0);
}
Aggregations