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

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

Issue 2377663002: [NTP Snippets] Introduce ContentSuggestion::ID (Closed)
Patch Set: rebase Created 4 years, 3 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
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java
index 7fb037243e4133847d51008b3c1b771c26403b64..2387d61973f529305d2a3c652773f24b19fee224 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java
@@ -18,8 +18,8 @@ public class SnippetArticle implements NewTabPageItem {
/** The category of this article. */
public final int mCategory;
- /** The unique identifier for this article. */
- public final String mId;
+ /** The identifier for this article within the category - not necessarily unique globally. */
+ public final String mIdWithinCategory;
/** The title of this article. */
public final String mTitle;
@@ -64,11 +64,11 @@ public class SnippetArticle implements NewTabPageItem {
/**
* Creates a SnippetArticleListItem object that will hold the data.
*/
- public SnippetArticle(int category, String id, String title, String publisher,
+ public SnippetArticle(int category, String idWithinCategory, String title, String publisher,
String previewText, String url, String ampUrl, long timestamp, float score,
int position, @ContentSuggestionsCardLayoutEnum int cardLayout) {
mCategory = category;
- mId = id;
+ mIdWithinCategory = idWithinCategory;
mTitle = title;
mPublisher = publisher;
mPreviewText = previewText;
@@ -83,12 +83,13 @@ public class SnippetArticle implements NewTabPageItem {
@Override
public boolean equals(Object other) {
if (!(other instanceof SnippetArticle)) return false;
- return mId.equals(((SnippetArticle) other).mId);
+ SnippetArticle rhs = (SnippetArticle) other;
+ return mCategory == rhs.mCategory && mIdWithinCategory.equals(rhs.mIdWithinCategory);
}
@Override
public int hashCode() {
- return mId.hashCode();
+ return mCategory ^ mIdWithinCategory.hashCode();
}
@Override

Powered by Google App Engine
This is Rietveld 408576698