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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/Leaf.java

Issue 2396523002: Unify NewTabPageItem and ItemGroup into a single tree-structured interface. (Closed)
Patch Set: review 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
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698