Example usage for android.widget Toolbar findViewById

List of usage examples for android.widget Toolbar findViewById

Introduction

In this page you can find the example usage for android.widget Toolbar findViewById.

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:io.plaidapp.ui.DesignerNewsStory.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_designer_news_story);
    ButterKnife.bind(this);
    getWindow().getSharedElementReturnTransition().addListener(returnHomeListener);

    story = getIntent().getParcelableExtra(EXTRA_STORY);
    fab.setOnClickListener(fabClick);//from w w w.j ava 2 s .  c om

    chromeFader = new ElasticDragDismissFrameLayout.SystemChromeFader(getWindow()) {
        @Override
        public void onDragDismissed() {
            finishAfterTransition();
        }
    };

    markdown = new Bypass(this,
            new Bypass.Options()
                    .setBlockQuoteLineColor(ContextCompat.getColor(this, R.color.designer_news_quote_line))
                    .setBlockQuoteLineWidth(2) // dps
                    .setBlockQuoteLineIndent(8) // dps
                    .setPreImageLinebreakHeight(4) //dps
                    .setBlockQuoteIndentSize(TypedValue.COMPLEX_UNIT_DIP, 2f)
                    .setBlockQuoteTextColor(ContextCompat.getColor(this, R.color.designer_news_quote)));
    circleTransform = new CircleTransform(this);

    designerNewsPrefs = DesignerNewsPrefs.get(this);
    createDesignerNewsApi();

    layoutManager = new LinearLayoutManager(this);
    commentsList.setLayoutManager(layoutManager);
    commentsList.setItemAnimator(new CommentAnimator());

    header = getLayoutInflater().inflate(R.layout.designer_news_story_description, commentsList, false);
    bindDescription();

    // setup toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.story_toolbar);
    if (collapsingToolbar != null) { // portrait: collapsing toolbar
        collapsingToolbar.addOnLayoutChangeListener(titlebarLayout);
        collapsingToolbar.setTitle(story.title);
    } else { // landscape: scroll toolbar with content
        toolbar = (Toolbar) header.findViewById(R.id.story_toolbar);
        FontTextView title = (FontTextView) toolbar.findViewById(R.id.story_title);
        title.setText(story.title);
    }
    commentsList.addOnScrollListener(headerScrollListener);

    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finishAfterTransition();
        }
    });

    View enterCommentView = setupCommentField();

    if (story.comment_count > 0) {
        // flatten the comments from a nested structure {@see Comment#comments} to a
        // list appropriate for our adapter (using the depth attribute).
        List<Comment> flattened = new ArrayList<>(story.comment_count);
        unnestComments(story.comments, flattened);
        commentsAdapter = new DesignerNewsCommentsAdapter(header, flattened, enterCommentView);
        commentsList.setAdapter(commentsAdapter);

    } else {
        commentsAdapter = new DesignerNewsCommentsAdapter(header, new ArrayList<Comment>(0), enterCommentView);
        commentsList.setAdapter(commentsAdapter);
    }
    customTab = new CustomTabActivityHelper();
    customTab.setConnectionCallback(customTabConnect);
}