| 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 android.support.annotation.IntDef; | |
| 8 import android.support.v7.widget.RecyclerView.Adapter; | |
| 9 | |
| 10 import java.lang.annotation.Retention; | |
| 11 import java.lang.annotation.RetentionPolicy; | |
| 12 | |
| 13 /** Base type for anything to add to the new tab page */ | |
| 14 public interface NewTabPageItem { | |
| 15 /** | |
| 16 * View type values for the items that will be held by the NTP's RecyclerVie
w. | |
| 17 * @see Adapter#getItemViewType(int) | |
| 18 * @see NewTabPageItem#getType() | |
| 19 */ | |
| 20 @IntDef({VIEW_TYPE_ABOVE_THE_FOLD, VIEW_TYPE_HEADER, VIEW_TYPE_SNIPPET, VIEW
_TYPE_SPACING, | |
| 21 VIEW_TYPE_STATUS, VIEW_TYPE_PROGRESS, VIEW_TYPE_ACTION, VIEW_TYPE_FO
OTER, | |
| 22 VIEW_TYPE_PROMO, VIEW_TYPE_ALL_DISMISSED}) | |
| 23 @Retention(RetentionPolicy.SOURCE) | |
| 24 public @interface ViewType {} | |
| 25 | |
| 26 /** | |
| 27 * View type for the above the fold item | |
| 28 * @see Adapter#getItemViewType(int) | |
| 29 */ | |
| 30 public static final int VIEW_TYPE_ABOVE_THE_FOLD = 1; | |
| 31 | |
| 32 /** | |
| 33 * View type for card group headers | |
| 34 * @see Adapter#getItemViewType(int) | |
| 35 */ | |
| 36 public static final int VIEW_TYPE_HEADER = 2; | |
| 37 | |
| 38 /** | |
| 39 * View type for snippet cards | |
| 40 * @see Adapter#getItemViewType(int) | |
| 41 */ | |
| 42 public static final int VIEW_TYPE_SNIPPET = 3; | |
| 43 | |
| 44 /** | |
| 45 * View type for a {@link SpacingItem} used to provide spacing at the end o
f the list. | |
| 46 * @see Adapter#getItemViewType(int) | |
| 47 */ | |
| 48 public static final int VIEW_TYPE_SPACING = 4; | |
| 49 | |
| 50 /** | |
| 51 * View type for a {@link StatusItem}, the card displaying status informatio
n | |
| 52 * @see Adapter#getItemViewType(int) | |
| 53 */ | |
| 54 public static final int VIEW_TYPE_STATUS = 5; | |
| 55 | |
| 56 /** | |
| 57 * View type for a {@link ProgressItem}, the progress indicator. | |
| 58 * @see Adapter#getItemViewType(int) | |
| 59 */ | |
| 60 public static final int VIEW_TYPE_PROGRESS = 6; | |
| 61 | |
| 62 /** | |
| 63 * View type for a {@link ActionItem}, an action button. | |
| 64 * @see Adapter#getItemViewType(int) | |
| 65 */ | |
| 66 public static final int VIEW_TYPE_ACTION = 7; | |
| 67 | |
| 68 /** | |
| 69 * View type for a {@link Footer}. | |
| 70 * @see Adapter#getItemViewType(int) | |
| 71 */ | |
| 72 public static final int VIEW_TYPE_FOOTER = 8; | |
| 73 | |
| 74 /** | |
| 75 * View type for a {@link SignInPromo}. | |
| 76 * @see Adapter#getItemViewType(int) | |
| 77 */ | |
| 78 public static final int VIEW_TYPE_PROMO = 9; | |
| 79 | |
| 80 /** | |
| 81 * View type for a {@link AllDismissedItem}. | |
| 82 * @see Adapter#getItemViewType(int) | |
| 83 */ | |
| 84 public static final int VIEW_TYPE_ALL_DISMISSED = 10; | |
| 85 | |
| 86 // NOTE: when adding new entries here, also update the IntDef at the top of
this file, and | |
| 87 // CardViewHolder#isCard(int type). | |
| 88 | |
| 89 /** | |
| 90 * Returns the type ({@link ViewType}) of this list item. This is so we can | |
| 91 * distinguish between different elements that are held in a single Recycle
rView holder. | |
| 92 * | |
| 93 * @return the type of this list item. | |
| 94 */ | |
| 95 @ViewType | |
| 96 public int getType(); | |
| 97 | |
| 98 /** | |
| 99 * Update the given {@link NewTabPageViewHolder} with data from this item. | |
| 100 * @param holder The {@link NewTabPageViewHolder} to update. | |
| 101 */ | |
| 102 void onBindViewHolder(NewTabPageViewHolder holder); | |
| 103 } | |
| OLD | NEW |