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.snippets; | 5 package org.chromium.chrome.browser.ntp.snippets; |
6 | 6 |
7 import org.chromium.chrome.browser.ntp.cards.NewTabPageItem; | 7 import org.chromium.chrome.browser.ntp.cards.ItemViewType; |
| 8 import org.chromium.chrome.browser.ntp.cards.Leaf; |
8 import org.chromium.chrome.browser.ntp.cards.NewTabPageViewHolder; | 9 import org.chromium.chrome.browser.ntp.cards.NewTabPageViewHolder; |
9 | 10 |
10 /** | 11 /** |
11 * Represents the data for a header of a group of snippets | 12 * Represents the data for a header of a group of snippets |
12 */ | 13 */ |
13 public class SectionHeader implements NewTabPageItem { | 14 public class SectionHeader extends Leaf { |
14 /** Whether the header should be shown. */ | 15 /** Whether the header should be shown. */ |
15 private final boolean mVisible; | 16 private final boolean mVisible; |
16 | 17 |
17 /** The header text to be shown. */ | 18 /** The header text to be shown. */ |
18 private final String mHeaderText; | 19 private final String mHeaderText; |
19 | 20 |
20 public SectionHeader(String headerText) { | 21 public SectionHeader(String headerText) { |
21 // TODO(mvanouwerkerk): Configure mVisible in the constructor when we ha
ve a global status | 22 // TODO(mvanouwerkerk): Configure mVisible in the constructor when we ha
ve a global status |
22 // section without a visible header. | 23 // section without a visible header. |
23 mVisible = true; | 24 mVisible = true; |
24 | 25 |
25 this.mHeaderText = headerText; | 26 this.mHeaderText = headerText; |
26 } | 27 } |
27 | 28 |
28 @Override | 29 @Override |
29 public int getType() { | 30 @ItemViewType |
30 return NewTabPageItem.VIEW_TYPE_HEADER; | 31 public int getItemViewType() { |
| 32 return ItemViewType.HEADER; |
31 } | 33 } |
32 | 34 |
33 public boolean isVisible() { | 35 public boolean isVisible() { |
34 return mVisible; | 36 return mVisible; |
35 } | 37 } |
36 | 38 |
37 public String getHeaderText() { | 39 public String getHeaderText() { |
38 return mHeaderText; | 40 return mHeaderText; |
39 } | 41 } |
40 | 42 |
41 @Override | 43 @Override |
42 public void onBindViewHolder(NewTabPageViewHolder holder) { | 44 protected void onBindViewHolder(NewTabPageViewHolder holder) { |
43 assert holder instanceof SectionHeaderViewHolder; | 45 assert holder instanceof SectionHeaderViewHolder; |
44 ((SectionHeaderViewHolder) holder).onBindViewHolder(this); | 46 ((SectionHeaderViewHolder) holder).onBindViewHolder(this); |
45 } | 47 } |
46 } | 48 } |
OLD | NEW |