| OLD | NEW |
| 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 Loading... |
| 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. */ | |
| 40 public final int mPosition; | |
| 41 | |
| 42 /** The position of this article in the complete list. Populated by NewTabPa
geAdapter. */ | |
| 43 public int mGlobalPosition = -1; | |
| 44 | |
| 45 /** Bitmap of the thumbnail, fetched lazily, when the RecyclerView wants to
show the snippet. */ | 39 /** Bitmap of the thumbnail, fetched lazily, when the RecyclerView wants to
show the snippet. */ |
| 46 private Bitmap mThumbnailBitmap; | 40 private Bitmap mThumbnailBitmap; |
| 47 | 41 |
| 48 /** Stores whether impression of this article has been tracked already. */ | 42 /** Stores whether impression of this article has been tracked already. */ |
| 49 private boolean mImpressionTracked; | 43 private boolean mImpressionTracked; |
| 50 | 44 |
| 51 /** To be run when the offline status of the article changes. */ | 45 /** To be run when the offline status of the article changes. */ |
| 52 private Runnable mOfflineStatusChangeRunnable; | 46 private Runnable mOfflineStatusChangeRunnable; |
| 53 | 47 |
| 54 /** Whether the linked article represents an asset download. */ | 48 /** Whether the linked article represents an asset download. */ |
| 55 public boolean mIsAssetDownload; | 49 public boolean mIsAssetDownload; |
| 56 | 50 |
| 57 /** The path to the asset download (only for asset download articles). */ | 51 /** The path to the asset download (only for asset download articles). */ |
| 58 private File mAssetDownloadFile; | 52 private File mAssetDownloadFile; |
| 59 | 53 |
| 60 /** The mime type of the asset download (only for asset download articles).
*/ | 54 /** The mime type of the asset download (only for asset download articles).
*/ |
| 61 private String mAssetDownloadMimeType; | 55 private String mAssetDownloadMimeType; |
| 62 | 56 |
| 63 /** The tab id of the corresponding tab (only for recent tab articles). */ | 57 /** The tab id of the corresponding tab (only for recent tab articles). */ |
| 64 private String mRecentTabId; | 58 private String mRecentTabId; |
| 65 | 59 |
| 66 /** The offline id of the corresponding offline page, if any. */ | 60 /** The offline id of the corresponding offline page, if any. */ |
| 67 private Long mOfflinePageOfflineId; | 61 private Long mOfflinePageOfflineId; |
| 68 | 62 |
| 69 /** | 63 /** |
| 70 * Creates a SnippetArticleListItem object that will hold the data. | 64 * Creates a SnippetArticleListItem object that will hold the data. |
| 71 */ | 65 */ |
| 72 public SnippetArticle(int category, String idWithinCategory, String title, S
tring publisher, | 66 public SnippetArticle(int category, String idWithinCategory, String title, S
tring publisher, |
| 73 String previewText, String url, long timestamp, float score, int pos
ition) { | 67 String previewText, String url, long timestamp, float score) { |
| 74 mCategory = category; | 68 mCategory = category; |
| 75 mIdWithinCategory = idWithinCategory; | 69 mIdWithinCategory = idWithinCategory; |
| 76 mTitle = title; | 70 mTitle = title; |
| 77 mPublisher = publisher; | 71 mPublisher = publisher; |
| 78 mPreviewText = previewText; | 72 mPreviewText = previewText; |
| 79 mUrl = url; | 73 mUrl = url; |
| 80 mPublishTimestampMilliseconds = timestamp; | 74 mPublishTimestampMilliseconds = timestamp; |
| 81 mScore = score; | 75 mScore = score; |
| 82 mPosition = position; | |
| 83 } | 76 } |
| 84 | 77 |
| 85 @Override | 78 @Override |
| 86 public boolean equals(Object other) { | 79 public boolean equals(Object other) { |
| 87 if (!(other instanceof SnippetArticle)) return false; | 80 if (!(other instanceof SnippetArticle)) return false; |
| 88 SnippetArticle rhs = (SnippetArticle) other; | 81 SnippetArticle rhs = (SnippetArticle) other; |
| 89 return mCategory == rhs.mCategory && mIdWithinCategory.equals(rhs.mIdWit
hinCategory); | 82 return mCategory == rhs.mCategory && mIdWithinCategory.equals(rhs.mIdWit
hinCategory); |
| 90 } | 83 } |
| 91 | 84 |
| 92 @Override | 85 @Override |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 public Long getOfflinePageOfflineId() { | 213 public Long getOfflinePageOfflineId() { |
| 221 return mOfflinePageOfflineId; | 214 return mOfflinePageOfflineId; |
| 222 } | 215 } |
| 223 | 216 |
| 224 @Override | 217 @Override |
| 225 public String toString() { | 218 public String toString() { |
| 226 // For debugging purposes. Displays the first 42 characters of the title
. | 219 // For debugging purposes. Displays the first 42 characters of the title
. |
| 227 return String.format("{%s, %1.42s}", getClass().getSimpleName(), mTitle)
; | 220 return String.format("{%s, %1.42s}", getClass().getSimpleName(), mTitle)
; |
| 228 } | 221 } |
| 229 } | 222 } |
| OLD | NEW |