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

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

Issue 2396523002: Unify NewTabPageItem and ItemGroup into a single tree-structured interface. (Closed)
Patch Set: oo Created 4 years, 2 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 7
8 import org.chromium.chrome.browser.ntp.cards.NewTabPageItem; 8 import org.chromium.chrome.browser.ntp.cards.ItemViewType;
9 import org.chromium.chrome.browser.ntp.cards.Leaf;
9 import org.chromium.chrome.browser.ntp.cards.NewTabPageViewHolder; 10 import org.chromium.chrome.browser.ntp.cards.NewTabPageViewHolder;
10 import org.chromium.chrome.browser.ntp.snippets.ContentSuggestionsCardLayout.Con tentSuggestionsCardLayoutEnum; 11 import org.chromium.chrome.browser.ntp.snippets.ContentSuggestionsCardLayout.Con tentSuggestionsCardLayoutEnum;
11 12
12 /** 13 /**
13 * Represents the data for an article card on the NTP. 14 * Represents the data for an article card on the NTP.
14 */ 15 */
15 public class SnippetArticle implements NewTabPageItem { 16 public class SnippetArticle extends Leaf {
16 /** The category of this article. */ 17 /** The category of this article. */
17 public final int mCategory; 18 public final int mCategory;
18 19
19 /** The identifier for this article within the category - not necessarily un ique globally. */ 20 /** The identifier for this article within the category - not necessarily un ique globally. */
20 public final String mIdWithinCategory; 21 public final String mIdWithinCategory;
21 22
22 /** The title of this article. */ 23 /** The title of this article. */
23 public final String mTitle; 24 public final String mTitle;
24 25
25 /** The canonical publisher name (e.g., New York Times). */ 26 /** The canonical publisher name (e.g., New York Times). */
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 SnippetArticle rhs = (SnippetArticle) other; 82 SnippetArticle rhs = (SnippetArticle) other;
82 return mCategory == rhs.mCategory && mIdWithinCategory.equals(rhs.mIdWit hinCategory); 83 return mCategory == rhs.mCategory && mIdWithinCategory.equals(rhs.mIdWit hinCategory);
83 } 84 }
84 85
85 @Override 86 @Override
86 public int hashCode() { 87 public int hashCode() {
87 return mCategory ^ mIdWithinCategory.hashCode(); 88 return mCategory ^ mIdWithinCategory.hashCode();
88 } 89 }
89 90
90 @Override 91 @Override
91 public int getType() { 92 @ItemViewType
92 return NewTabPageItem.VIEW_TYPE_SNIPPET; 93 public int getItemViewType() {
94 return ItemViewType.VIEW_TYPE_SNIPPET;
93 } 95 }
94 96
95 @Override 97 @Override
96 public void onBindViewHolder(NewTabPageViewHolder holder) { 98 protected void onBindViewHolder(NewTabPageViewHolder holder) {
97 assert holder instanceof SnippetArticleViewHolder; 99 assert holder instanceof SnippetArticleViewHolder;
98 ((SnippetArticleViewHolder) holder).onBindViewHolder(this); 100 ((SnippetArticleViewHolder) holder).onBindViewHolder(this);
99 } 101 }
100 102
101 /** 103 /**
102 * Returns this article's thumbnail as a {@link Bitmap}. Can return {@code n ull} as it is 104 * Returns this article's thumbnail as a {@link Bitmap}. Can return {@code n ull} as it is
103 * initially unset. 105 * initially unset.
104 */ 106 */
105 public Bitmap getThumbnailBitmap() { 107 public Bitmap getThumbnailBitmap() {
106 return mThumbnailBitmap; 108 return mThumbnailBitmap;
(...skipping 11 matching lines...) Expand all
118 mImpressionTracked = true; 120 mImpressionTracked = true;
119 return true; 121 return true;
120 } 122 }
121 123
122 @Override 124 @Override
123 public String toString() { 125 public String toString() {
124 // For debugging purposes. Displays the first 42 characters of the title . 126 // For debugging purposes. Displays the first 42 characters of the title .
125 return String.format("{%s, %1.42s}", getClass().getSimpleName(), mTitle) ; 127 return String.format("{%s, %1.42s}", getClass().getSimpleName(), mTitle) ;
126 } 128 }
127 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698