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.ItemViewType; | 7 import org.chromium.chrome.browser.ntp.cards.ItemViewType; |
8 import org.chromium.chrome.browser.ntp.cards.NewTabPageViewHolder; | 8 import org.chromium.chrome.browser.ntp.cards.NewTabPageViewHolder; |
| 9 import org.chromium.chrome.browser.ntp.cards.NodeVisitor; |
9 import org.chromium.chrome.browser.ntp.cards.OptionalLeaf; | 10 import org.chromium.chrome.browser.ntp.cards.OptionalLeaf; |
10 | 11 |
11 /** | 12 /** |
12 * Represents the data for a header of a group of snippets | 13 * Represents the data for a header of a group of snippets. |
13 */ | 14 */ |
14 public class SectionHeader extends OptionalLeaf { | 15 public class SectionHeader extends OptionalLeaf { |
15 /** The header text to be shown. */ | 16 /** The header text to be shown. */ |
16 private final String mHeaderText; | 17 private final String mHeaderText; |
17 | 18 |
18 public SectionHeader(String headerText) { | 19 public SectionHeader(String headerText) { |
19 this.mHeaderText = headerText; | 20 this.mHeaderText = headerText; |
20 setVisible(true); | 21 setVisible(true); |
21 } | 22 } |
22 | 23 |
23 @Override | 24 @Override |
24 @ItemViewType | 25 @ItemViewType |
25 public int getItemViewType() { | 26 public int getItemViewType() { |
26 return ItemViewType.HEADER; | 27 return ItemViewType.HEADER; |
27 } | 28 } |
28 | 29 |
29 public String getHeaderText() { | 30 public String getHeaderText() { |
30 return mHeaderText; | 31 return mHeaderText; |
31 } | 32 } |
32 | 33 |
33 @Override | 34 @Override |
34 protected void onBindViewHolder(NewTabPageViewHolder holder) { | 35 protected void onBindViewHolder(NewTabPageViewHolder holder) { |
35 assert holder instanceof SectionHeaderViewHolder; | 36 assert holder instanceof SectionHeaderViewHolder; |
36 ((SectionHeaderViewHolder) holder).onBindViewHolder(this); | 37 ((SectionHeaderViewHolder) holder).onBindViewHolder(this); |
37 } | 38 } |
38 } | 39 |
| 40 @Override |
| 41 public void visitOptionalItem(NodeVisitor visitor) { |
| 42 visitor.visitHeader(); |
| 43 } |
| 44 } |
OLD | NEW |