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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/TreeNode.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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/TreeNode.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/TreeNode.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/TreeNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..d05487539a4c70aeeb12166b5b5bdfb2ec5399f7
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/TreeNode.java
@@ -0,0 +1,41 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.ntp.cards;
+
+import org.chromium.chrome.browser.ntp.snippets.SnippetArticle;
+
+/**
+ * A tree interface to allow the New Tab Page RecyclerView to delegate to other components.
+ */
+interface TreeNode {
+ /**
+ * @return The number of items under this subtree.
+ * @see android.support.v7.widget.RecyclerView.Adapter#getItemCount()
+ */
+ int getItemCount();
+
+ /**
+ * @param position The position to query
+ * @return The view type of the item at {@code position} under this subtree.
+ * @see android.support.v7.widget.RecyclerView.Adapter#getItemViewType
+ */
+ @ItemViewType
+ int getItemViewType(int position);
+
+ /**
+ * Display the data at {@code position} under this subtree.
+ * @param holder The view holder that should be updated.
+ * @param position The position of the item under this subtree.
+ * @see android.support.v7.widget.RecyclerView.Adapter#onBindViewHolder
+ */
+ void onBindViewHolder(NewTabPageViewHolder holder, final int position);
+
+ /**
+ * @param position The position to query.
+ * @return The article at {@code position} under this subtree, or null if the item is not
+ * an article.
+ */
+ SnippetArticle getSuggestionAt(int position);
+}

Powered by Google App Engine
This is Rietveld 408576698