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

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

Issue 2618893003: 📰 Tweak the suggestion ranks for UMA to handle fetchMore (Closed)
Patch Set: rebase, address comments Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 package org.chromium.chrome.browser.ntp.snippets; 4 package org.chromium.chrome.browser.ntp.snippets;
5 5
6 import android.graphics.Bitmap; 6 import android.graphics.Bitmap;
7 import android.support.annotation.Nullable; 7 import android.support.annotation.Nullable;
8 8
9 import java.io.File; 9 import java.io.File;
10 10
(...skipping 18 matching lines...) Expand all
29 29
30 /** The URL of this article. This may be an AMP url. */ 30 /** The URL of this article. This may be an AMP url. */
31 public final String mUrl; 31 public final String mUrl;
32 32
33 /** The time when this article was published. */ 33 /** The time when this article was published. */
34 public final long mPublishTimestampMilliseconds; 34 public final long mPublishTimestampMilliseconds;
35 35
36 /** The score expressing relative quality of the article for the user. */ 36 /** The score expressing relative quality of the article for the user. */
37 public final float mScore; 37 public final float mScore;
38 38
39 /** The position of this article within its section. */ 39 /** The rank of this article within its section. */
40 public final int mPosition; 40 private int mPerSectionRank = -1;
41 41
42 /** The position of this article in the complete list. Populated by NewTabPa geAdapter. */ 42 /** The global rank of this article in the complete list. */
43 public int mGlobalPosition = -1; 43 private int mGlobalRank = -1;
44 44
45 /** Bitmap of the thumbnail, fetched lazily, when the RecyclerView wants to show the snippet. */ 45 /** Bitmap of the thumbnail, fetched lazily, when the RecyclerView wants to show the snippet. */
46 private Bitmap mThumbnailBitmap; 46 private Bitmap mThumbnailBitmap;
47 47
48 /** Stores whether impression of this article has been tracked already. */ 48 /** Stores whether impression of this article has been tracked already. */
49 private boolean mImpressionTracked; 49 private boolean mImpressionTracked;
50 50
51 /** Whether the linked article represents an asset download. */ 51 /** Whether the linked article represents an asset download. */
52 public boolean mIsAssetDownload; 52 public boolean mIsAssetDownload;
53 53
54 /** The path to the asset download (only for asset download articles). */ 54 /** The path to the asset download (only for asset download articles). */
55 private File mAssetDownloadFile; 55 private File mAssetDownloadFile;
56 56
57 /** The mime type of the asset download (only for asset download articles). */ 57 /** The mime type of the asset download (only for asset download articles). */
58 private String mAssetDownloadMimeType; 58 private String mAssetDownloadMimeType;
59 59
60 /** The tab id of the corresponding tab (only for recent tab articles). */ 60 /** The tab id of the corresponding tab (only for recent tab articles). */
61 private String mRecentTabId; 61 private String mRecentTabId;
62 62
63 /** The offline id of the corresponding offline page, if any. */ 63 /** The offline id of the corresponding offline page, if any. */
64 private Long mOfflinePageOfflineId; 64 private Long mOfflinePageOfflineId;
65 65
66 /** 66 /**
67 * Creates a SnippetArticleListItem object that will hold the data. 67 * Creates a SnippetArticleListItem object that will hold the data.
68 */ 68 */
69 public SnippetArticle(int category, String idWithinCategory, String title, S tring publisher, 69 public SnippetArticle(int category, String idWithinCategory, String title, S tring publisher,
70 String previewText, String url, long timestamp, float score, int pos ition) { 70 String previewText, String url, long timestamp, float score) {
71 mCategory = category; 71 mCategory = category;
72 mIdWithinCategory = idWithinCategory; 72 mIdWithinCategory = idWithinCategory;
73 mTitle = title; 73 mTitle = title;
74 mPublisher = publisher; 74 mPublisher = publisher;
75 mPreviewText = previewText; 75 mPreviewText = previewText;
76 mUrl = url; 76 mUrl = url;
77 mPublishTimestampMilliseconds = timestamp; 77 mPublishTimestampMilliseconds = timestamp;
78 mScore = score; 78 mScore = score;
79 mPosition = position;
80 } 79 }
81 80
82 @Override 81 @Override
83 public boolean equals(Object other) { 82 public boolean equals(Object other) {
84 if (!(other instanceof SnippetArticle)) return false; 83 if (!(other instanceof SnippetArticle)) return false;
85 SnippetArticle rhs = (SnippetArticle) other; 84 SnippetArticle rhs = (SnippetArticle) other;
86 return mCategory == rhs.mCategory && mIdWithinCategory.equals(rhs.mIdWit hinCategory); 85 return mCategory == rhs.mCategory && mIdWithinCategory.equals(rhs.mIdWit hinCategory);
87 } 86 }
88 87
89 @Override 88 @Override
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 @Nullable 200 @Nullable
202 public Long getOfflinePageOfflineId() { 201 public Long getOfflinePageOfflineId() {
203 return mOfflinePageOfflineId; 202 return mOfflinePageOfflineId;
204 } 203 }
205 204
206 @Override 205 @Override
207 public String toString() { 206 public String toString() {
208 // For debugging purposes. Displays the first 42 characters of the title . 207 // For debugging purposes. Displays the first 42 characters of the title .
209 return String.format("{%s, %1.42s}", getClass().getSimpleName(), mTitle) ; 208 return String.format("{%s, %1.42s}", getClass().getSimpleName(), mTitle) ;
210 } 209 }
210
211 public void setRank(int perSectionRank, int globalRank) {
212 mPerSectionRank = perSectionRank;
213 mGlobalRank = globalRank;
214 }
215
216 public int getGlobalRank() {
217 return mGlobalRank;
218 }
219
220 public int getPerSectionRank() {
221 return mPerSectionRank;
222 }
211 } 223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698