use of io.plaidapp.core.util.customtabs.CustomTabActivityHelper in project plaid by nickbutcher.
the class StoryActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_designer_news_story);
long storyId = getIntent().getLongExtra(Activities.DesignerNews.Story.EXTRA_STORY_ID, -1);
if (storyId == -1) {
finishAfterTransition();
}
Injector.inject(storyId, this);
bindResources();
story = viewModel.getStory();
viewModel.getUiModel().observe(this, storyUiModel -> setupComments(storyUiModel.getComments()));
fab.setOnClickListener(fabClick);
chromeFader = new ElasticDragDismissFrameLayout.SystemChromeFader(this);
layoutManager = new LinearLayoutManager(this);
commentsList.setLayoutManager(layoutManager);
commentsList.setItemAnimator(new CommentAnimator(getResources().getInteger(io.plaidapp.R.integer.comment_expand_collapse_duration)));
header = getLayoutInflater().inflate(R.layout.designer_news_story_description, commentsList, false);
bindDescription();
// setup title/toolbar
if (collapsingToolbar != null) {
// narrow device: collapsing toolbar
collapsingToolbar.addOnLayoutChangeListener(titlebarLayout);
collapsingToolbar.setTitle(story.getTitle());
final Toolbar toolbar = findViewById(R.id.story_toolbar);
toolbar.setNavigationOnClickListener(backClick);
commentsList.addOnScrollListener(headerScrollListener);
setEnterSharedElementCallback(new SharedElementCallback() {
@Override
public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
ReflowText.setupReflow(getIntent(), collapsingToolbar);
}
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
ReflowText.setupReflow(collapsingToolbar);
}
});
} else {
// w600dp configuration: content card scrolls over title bar
final TextView title = findViewById(R.id.story_title);
title.setText(story.getTitle());
findViewById(R.id.back).setOnClickListener(backClick);
}
enterCommentView = setupCommentField();
commentsAdapter = new DesignerNewsCommentsAdapter(header, new ArrayList<>(0), enterCommentView);
commentsList.setAdapter(commentsAdapter);
draggableFrame.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
final int stableListPaddingBottom = commentsList.getPaddingBottom();
final int stableListPaddingLeft = commentsList.getPaddingLeft();
final int stableListPaddingRight = commentsList.getPaddingRight();
final int stableFabMarginBottom = ((MarginLayoutParams) fab.getLayoutParams()).bottomMargin;
final int stableFabMarginRight = ((MarginLayoutParams) fab.getLayoutParams()).rightMargin;
final View back = findViewById(R.id.back);
final int stableBackMarginLeft = back == null ? 0 : ((MarginLayoutParams) back.getLayoutParams()).leftMargin;
draggableFrame.setOnApplyWindowInsetsListener((v, insets) -> {
final MarginLayoutParams listLp = (MarginLayoutParams) v.getLayoutParams();
listLp.topMargin = insets.getSystemWindowInsetTop();
v.setLayoutParams(listLp);
commentsList.setPadding(stableListPaddingLeft + commentsList.getPaddingLeft(), commentsList.getPaddingTop(), stableListPaddingRight + insets.getSystemWindowInsetRight(), stableListPaddingBottom + insets.getSystemWindowInsetBottom());
final MarginLayoutParams fabLp = (MarginLayoutParams) fab.getLayoutParams();
fabLp.rightMargin = stableFabMarginRight + insets.getSystemWindowInsetRight();
fabLp.bottomMargin = stableFabMarginBottom + insets.getSystemWindowInsetBottom();
fab.setLayoutParams(fabLp);
if (back != null) {
final MarginLayoutParams backLp = (MarginLayoutParams) back.getLayoutParams();
backLp.leftMargin = stableBackMarginLeft + insets.getSystemWindowInsetLeft();
}
return insets;
});
customTab = new CustomTabActivityHelper();
customTab.setConnectionCallback(customTabConnect);
}
Aggregations