Search in sources :

Example 16 with StyledText

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);
}
Also used : StyledText(com.github.pockethub.android.ui.StyledText) OnClickListener(android.view.View.OnClickListener) Folder(com.github.pockethub.android.core.code.FullTree.Folder) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Aggregations

StyledText (com.github.pockethub.android.ui.StyledText)16 TextView (android.widget.TextView)3 User (com.meisolsson.githubsdk.model.User)3 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 GitHubFile (com.meisolsson.githubsdk.model.GitHubFile)2 Date (java.util.Date)2 Resources (android.content.res.Resources)1 Paint (android.graphics.Paint)1 Rect (android.graphics.Rect)1 OnClickListener (android.view.View.OnClickListener)1 ImageView (android.widget.ImageView)1 Folder (com.github.pockethub.android.core.code.FullTree.Folder)1 FullCommit (com.github.pockethub.android.core.commit.FullCommit)1 Commit (com.meisolsson.githubsdk.model.Commit)1 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)1 Label (com.meisolsson.githubsdk.model.Label)1 Milestone (com.meisolsson.githubsdk.model.Milestone)1 GitComment (com.meisolsson.githubsdk.model.git.GitComment)1