Commit e04941a0 authored by galinap's avatar galinap Committed by Commit bot

Removed whitespace when no headline is set in a snippet article.

Screenshots at
https://drive.google.com/drive/folders/0B7eRCSITD4qmelN0aEFMQXNwNTA?usp=sharing

BUG=716022

Review-Url: https://codereview.chromium.org/2849523004
Cr-Commit-Position: refs/heads/master@{#468007}
parent 4990bf6e
...@@ -233,21 +233,39 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi ...@@ -233,21 +233,39 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
final int verticalStyle = mUiConfig.getCurrentDisplayStyle().vertical; final int verticalStyle = mUiConfig.getCurrentDisplayStyle().vertical;
final int layout = mCategoryInfo.getCardLayout(); final int layout = mCategoryInfo.getCardLayout();
boolean showHeadline = shouldShowHeadline();
boolean showDescription = shouldShowDescription(horizontalStyle, verticalStyle, layout); boolean showDescription = shouldShowDescription(horizontalStyle, verticalStyle, layout);
boolean showThumbnail = shouldShowThumbnail(horizontalStyle, verticalStyle, layout); boolean showThumbnail = shouldShowThumbnail(horizontalStyle, verticalStyle, layout);
mHeadlineTextView.setVisibility(showHeadline ? View.VISIBLE : View.GONE);
mArticleSnippetTextView.setVisibility(showDescription ? View.VISIBLE : View.GONE); mArticleSnippetTextView.setVisibility(showDescription ? View.VISIBLE : View.GONE);
mThumbnailView.setVisibility(showThumbnail ? View.VISIBLE : View.GONE); mThumbnailView.setVisibility(showThumbnail ? View.VISIBLE : View.GONE);
// If we aren't showing the article snippet, reduce the top margin for publisher text. ViewGroup.MarginLayoutParams publisherBarParams =
ViewGroup.MarginLayoutParams params =
(ViewGroup.MarginLayoutParams) mPublisherBar.getLayoutParams(); (ViewGroup.MarginLayoutParams) mPublisherBar.getLayoutParams();
params.topMargin = mPublisherBar.getResources().getDimensionPixelSize(showDescription if (showDescription) {
? R.dimen.snippets_publisher_margin_top_with_article_snippet publisherBarParams.topMargin = mPublisherBar.getResources().getDimensionPixelSize(
: R.dimen.snippets_publisher_margin_top_without_article_snippet); R.dimen.snippets_publisher_margin_top_with_article_snippet);
ApiCompatibilityUtils.setMarginEnd(params, showThumbnail ? mThumbnailFootprintPx : 0); } else if (showHeadline) {
mPublisherBar.setLayoutParams(params); // When we show a headline and not a description, we reduce the top margin of the
// publisher bar.
publisherBarParams.topMargin = mPublisherBar.getResources().getDimensionPixelSize(
R.dimen.snippets_publisher_margin_top_without_article_snippet);
} else {
// When there is no headline and no description, we remove the top margin of the
// publisher bar.
publisherBarParams.topMargin = 0;
}
ApiCompatibilityUtils.setMarginEnd(
publisherBarParams, showThumbnail ? mThumbnailFootprintPx : 0);
mPublisherBar.setLayoutParams(publisherBarParams);
}
/** If the title is empty (or contains only whitespace characters), we do not show it. */
private boolean shouldShowHeadline() {
return !mArticle.mTitle.trim().isEmpty();
} }
private boolean shouldShowDescription(int horizontalStyle, int verticalStyle, int layout) { private boolean shouldShowDescription(int horizontalStyle, int verticalStyle, int layout) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment