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 org.chromium.base.ReferencePool; | |
9 import org.chromium.chrome.browser.suggestions.OfflinableSuggestion; | 10 import org.chromium.chrome.browser.suggestions.OfflinableSuggestion; |
10 | 11 |
11 import java.io.File; | 12 import java.io.File; |
12 | 13 |
13 /** | 14 /** |
14 * Represents the data for an article card on the NTP. | 15 * Represents the data for an article card on the NTP. |
15 */ | 16 */ |
16 public class SnippetArticle implements OfflinableSuggestion { | 17 public class SnippetArticle implements OfflinableSuggestion { |
17 /** The category of this article. */ | 18 /** The category of this article. */ |
18 public final int mCategory; | 19 public final int mCategory; |
(...skipping 25 matching lines...) Expand all Loading... | |
44 */ | 45 */ |
45 public final long mFetchTimestampMilliseconds; | 46 public final long mFetchTimestampMilliseconds; |
46 | 47 |
47 /** The rank of this article within its section. */ | 48 /** The rank of this article within its section. */ |
48 private int mPerSectionRank = -1; | 49 private int mPerSectionRank = -1; |
49 | 50 |
50 /** The global rank of this article in the complete list. */ | 51 /** The global rank of this article in the complete list. */ |
51 private int mGlobalRank = -1; | 52 private int mGlobalRank = -1; |
52 | 53 |
53 /** Bitmap of the thumbnail, fetched lazily, when the RecyclerView wants to show the snippet. */ | 54 /** Bitmap of the thumbnail, fetched lazily, when the RecyclerView wants to show the snippet. */ |
54 private Bitmap mThumbnailBitmap; | 55 private ReferencePool.Reference<Bitmap> mThumbnailBitmap; |
dgn
2017/05/08 17:01:51
nit: import ReferencePool.Reference? I find dotted
Bernhard Bauer
2017/05/09 08:51:10
Done. Eclipse auto-import always does it like this
| |
55 | 56 |
56 /** Stores whether impression of this article has been tracked already. */ | 57 /** Stores whether impression of this article has been tracked already. */ |
57 private boolean mImpressionTracked; | 58 private boolean mImpressionTracked; |
58 | 59 |
59 /** Whether the linked article represents an asset download. */ | 60 /** Whether the linked article represents an asset download. */ |
60 private boolean mIsAssetDownload; | 61 private boolean mIsAssetDownload; |
61 | 62 |
62 /** The GUID of the asset download (only for asset download articles). */ | 63 /** The GUID of the asset download (only for asset download articles). */ |
63 private String mAssetDownloadGuid; | 64 private String mAssetDownloadGuid; |
64 | 65 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 @Override | 102 @Override |
102 public int hashCode() { | 103 public int hashCode() { |
103 return mCategory ^ mIdWithinCategory.hashCode(); | 104 return mCategory ^ mIdWithinCategory.hashCode(); |
104 } | 105 } |
105 | 106 |
106 /** | 107 /** |
107 * Returns this article's thumbnail as a {@link Bitmap}. Can return {@code n ull} as it is | 108 * Returns this article's thumbnail as a {@link Bitmap}. Can return {@code n ull} as it is |
108 * initially unset. | 109 * initially unset. |
109 */ | 110 */ |
110 public Bitmap getThumbnailBitmap() { | 111 public Bitmap getThumbnailBitmap() { |
111 return mThumbnailBitmap; | 112 return mThumbnailBitmap == null ? null : mThumbnailBitmap.get(); |
112 } | 113 } |
113 | 114 |
114 /** Sets the thumbnail bitmap for this article. */ | 115 /** Sets the thumbnail bitmap for this article. */ |
115 public void setThumbnailBitmap(Bitmap bitmap) { | 116 public void setThumbnailBitmap(ReferencePool.Reference<Bitmap> bitmap) { |
116 mThumbnailBitmap = bitmap; | 117 mThumbnailBitmap = bitmap; |
117 } | 118 } |
118 | 119 |
119 /** Returns whether to track an impression for this article. */ | 120 /** Returns whether to track an impression for this article. */ |
120 public boolean trackImpression() { | 121 public boolean trackImpression() { |
121 // Track UMA only upon the first impression per life-time of this object . | 122 // Track UMA only upon the first impression per life-time of this object . |
122 if (mImpressionTracked) return false; | 123 if (mImpressionTracked) return false; |
123 mImpressionTracked = true; | 124 mImpressionTracked = true; |
124 return true; | 125 return true; |
125 } | 126 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 } | 248 } |
248 | 249 |
249 public int getGlobalRank() { | 250 public int getGlobalRank() { |
250 return mGlobalRank; | 251 return mGlobalRank; |
251 } | 252 } |
252 | 253 |
253 public int getPerSectionRank() { | 254 public int getPerSectionRank() { |
254 return mPerSectionRank; | 255 return mPerSectionRank; |
255 } | 256 } |
256 } | 257 } |
OLD | NEW |