Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2677)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java

Issue 2849523004: Removed whitespace when no headline is set in a snippet article. (Closed)
Patch Set: Rearrange the big if statement. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
index c839581dba9a823084511f241e7d86b3164b9936..03bde1e58642a8c1031cb6d11f1bd9e8480c5377 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
@@ -233,21 +233,39 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
final int verticalStyle = mUiConfig.getCurrentDisplayStyle().vertical;
final int layout = mCategoryInfo.getCardLayout();
+ boolean showHeadline = shouldShowHeadline();
boolean showDescription = shouldShowDescription(horizontalStyle, verticalStyle, layout);
boolean showThumbnail = shouldShowThumbnail(horizontalStyle, verticalStyle, layout);
+ mHeadlineTextView.setVisibility(showHeadline ? View.VISIBLE : View.GONE);
mArticleSnippetTextView.setVisibility(showDescription ? 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 params =
+ ViewGroup.MarginLayoutParams publisherBarParams =
(ViewGroup.MarginLayoutParams) mPublisherBar.getLayoutParams();
- params.topMargin = mPublisherBar.getResources().getDimensionPixelSize(showDescription
- ? R.dimen.snippets_publisher_margin_top_with_article_snippet
- : R.dimen.snippets_publisher_margin_top_without_article_snippet);
- ApiCompatibilityUtils.setMarginEnd(params, showThumbnail ? mThumbnailFootprintPx : 0);
- mPublisherBar.setLayoutParams(params);
+ if (showDescription) {
+ publisherBarParams.topMargin = mPublisherBar.getResources().getDimensionPixelSize(
+ R.dimen.snippets_publisher_margin_top_with_article_snippet);
+ } else if (showHeadline) {
+ // 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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698