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

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

Issue 2591673002: [NTP::PhysicalWeb] Do not show published time. (Closed)
Patch Set: mvanouwerkerk@ comments. Created 4 years 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 | components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.cc » ('j') | 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 3eb3a43cedbed68f480e5edf0336ebb4b41d407f..d313592dc429164d252dfad42e58a95b4cfc2695 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
@@ -185,39 +185,43 @@ public class SnippetArticleViewHolder
mPublisherBar.setLayoutParams(params);
}
- public void onBindViewHolder(SnippetArticle article, SuggestionsCategoryInfo categoryInfo) {
- super.onBindViewHolder();
-
- // No longer listen for offline status changes to the old article.
- if (mArticle != null) mArticle.setOfflineStatusChangeRunnable(null);
-
- mArticle = article;
- mCategoryInfo = categoryInfo;
- updateLayout();
-
- mHeadlineTextView.setText(mArticle.mTitle);
+ private static String getAttributionString(SnippetArticle article) {
+ if (article.mPublishTimestampMilliseconds == 0) return article.mPublisher;
// DateUtils.getRelativeTimeSpanString(...) calls through to TimeZone.getDefault(). If this
// has never been called before it loads the current time zone from disk. In most likelihood
// this will have been called previously and the current time zone will have been cached,
// but in some cases (eg instrumentation tests) it will cause a strict mode violation.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
+ CharSequence relativeTimeSpan;
try {
long time = SystemClock.elapsedRealtime();
- CharSequence relativeTimeSpan = DateUtils.getRelativeTimeSpanString(
- mArticle.mPublishTimestampMilliseconds, System.currentTimeMillis(),
- DateUtils.MINUTE_IN_MILLIS);
+ relativeTimeSpan =
+ DateUtils.getRelativeTimeSpanString(article.mPublishTimestampMilliseconds,
+ System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS);
RecordHistogram.recordTimesHistogram("Android.StrictMode.SnippetUIBuildTime",
SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS);
-
- // We format the publisher here so that having a publisher name in an RTL language
- // doesn't mess up the formatting on an LTR device and vice versa.
- String publisherAttribution = String.format(PUBLISHER_FORMAT_STRING,
- BidiFormatter.getInstance().unicodeWrap(mArticle.mPublisher), relativeTimeSpan);
- mPublisherTextView.setText(publisherAttribution);
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
+ // We format the publisher here so that having a publisher name in an RTL language
+ // doesn't mess up the formatting on an LTR device and vice versa.
+ return String.format(PUBLISHER_FORMAT_STRING,
+ BidiFormatter.getInstance().unicodeWrap(article.mPublisher), relativeTimeSpan);
+ }
+
+ public void onBindViewHolder(SnippetArticle article, SuggestionsCategoryInfo categoryInfo) {
+ super.onBindViewHolder();
+
+ // No longer listen for offline status changes to the old article.
+ if (mArticle != null) mArticle.setOfflineStatusChangeRunnable(null);
+
+ mArticle = article;
+ mCategoryInfo = categoryInfo;
+ updateLayout();
+
+ mHeadlineTextView.setText(mArticle.mTitle);
+ mPublisherTextView.setText(getAttributionString(mArticle));
// The favicon of the publisher should match the TextView height.
int widthSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
« no previous file with comments | « no previous file | components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698