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 | 4 |
5 package org.chromium.chrome.browser.ntp.cards; | 5 package org.chromium.chrome.browser.ntp.cards; |
6 | 6 |
7 import android.view.View; | 7 import android.view.View; |
8 | 8 |
9 import org.chromium.chrome.R; | 9 import org.chromium.chrome.R; |
10 import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager; | 10 import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager; |
11 import org.chromium.chrome.browser.ntp.UiConfig; | 11 import org.chromium.chrome.browser.ntp.UiConfig; |
12 | 12 |
13 /** | 13 /** |
14 * Item that allows the user to perform an action on the NTP. | 14 * Item that allows the user to perform an action on the NTP. |
15 */ | 15 */ |
16 class ActionItem implements NewTabPageItem { | 16 class ActionItem extends Leaf { |
17 private static final String TAG = "NtpCards"; | 17 private static final String TAG = "NtpCards"; |
18 | 18 |
19 private final SuggestionsCategoryInfo mCategoryInfo; | 19 private final SuggestionsCategoryInfo mCategoryInfo; |
20 | 20 |
21 // The position (index) of this item within its section, for logging purpose
s. | 21 // The position (index) of this item within its section, for logging purpose
s. |
22 private int mPosition; | 22 private int mPosition; |
23 private boolean mImpressionTracked = false; | 23 private boolean mImpressionTracked = false; |
24 private boolean mDismissable; | 24 private boolean mDismissable; |
25 | 25 |
26 public ActionItem(SuggestionsCategoryInfo categoryInfo) { | 26 public ActionItem(SuggestionsCategoryInfo categoryInfo) { |
27 mCategoryInfo = categoryInfo; | 27 mCategoryInfo = categoryInfo; |
28 } | 28 } |
29 | 29 |
30 @Override | 30 @Override |
31 public int getType() { | 31 @ItemViewType |
32 return NewTabPageItem.VIEW_TYPE_ACTION; | 32 protected int getItemViewType() { |
| 33 return ItemViewType.ACTION; |
33 } | 34 } |
34 | 35 |
35 public int getPosition() { | 36 public int getPosition() { |
36 return mPosition; | 37 return mPosition; |
37 } | 38 } |
38 | 39 |
39 public void setPosition(int position) { | 40 public void setPosition(int position) { |
40 mPosition = position; | 41 mPosition = position; |
41 } | 42 } |
42 | 43 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 public boolean isDismissable() { | 77 public boolean isDismissable() { |
77 return mActionListItem.mDismissable; | 78 return mActionListItem.mDismissable; |
78 } | 79 } |
79 | 80 |
80 public void onBindViewHolder(ActionItem item) { | 81 public void onBindViewHolder(ActionItem item) { |
81 mActionListItem = item; | 82 mActionListItem = item; |
82 } | 83 } |
83 } | 84 } |
84 | 85 |
85 @Override | 86 @Override |
86 public void onBindViewHolder(NewTabPageViewHolder holder) { | 87 protected void onBindViewHolder(NewTabPageViewHolder holder) { |
87 assert holder instanceof ViewHolder; | 88 assert holder instanceof ViewHolder; |
88 ((ViewHolder) holder).onBindViewHolder(this); | 89 ((ViewHolder) holder).onBindViewHolder(this); |
89 } | 90 } |
90 | 91 |
91 /** Set whether this item can be dismissed.*/ | 92 /** Set whether this item can be dismissed.*/ |
92 public void setDismissable(boolean dismissable) { | 93 public void setDismissable(boolean dismissable) { |
93 this.mDismissable = dismissable; | 94 this.mDismissable = dismissable; |
94 } | 95 } |
95 } | 96 } |
OLD | NEW |