OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.ntp.cards; |
| 6 |
| 7 import org.chromium.chrome.browser.ntp.snippets.SnippetArticle; |
| 8 |
| 9 /** |
| 10 * A leaf in the tree, i.e. a single item. |
| 11 */ |
| 12 public abstract class Leaf implements TreeNode { |
| 13 @Override |
| 14 public int getItemCount() { |
| 15 return 1; |
| 16 } |
| 17 |
| 18 @Override |
| 19 @ItemViewType |
| 20 public int getItemViewType(int position) { |
| 21 if (position != 0) throw new IndexOutOfBoundsException(); |
| 22 return getItemViewType(); |
| 23 } |
| 24 |
| 25 @Override |
| 26 public void onBindViewHolder(NewTabPageViewHolder holder, int position) { |
| 27 if (position != 0) throw new IndexOutOfBoundsException(); |
| 28 onBindViewHolder(holder); |
| 29 } |
| 30 |
| 31 @Override |
| 32 public SnippetArticle getSuggestionAt(int position) { |
| 33 if (position != 0) throw new IndexOutOfBoundsException(); |
| 34 |
| 35 return null; |
| 36 } |
| 37 |
| 38 /** |
| 39 * Display the data for this item. |
| 40 * @param holder The view holder that should be updated. |
| 41 * @see #onBindViewHolder(NewTabPageViewHolder, int) |
| 42 * @see android.support.v7.widget.RecyclerView.Adapter#onBindViewHolder |
| 43 */ |
| 44 protected abstract void onBindViewHolder(NewTabPageViewHolder holder); |
| 45 |
| 46 /** |
| 47 * @return The view type of this item. |
| 48 * @see android.support.v7.widget.RecyclerView.Adapter#getItemViewType |
| 49 */ |
| 50 @ItemViewType |
| 51 protected abstract int getItemViewType(); |
| 52 } |
OLD | NEW |