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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ChildNode.java

Issue 2396523002: Unify NewTabPageItem and ItemGroup into a single tree-structured interface. (Closed)
Patch Set: oo 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/ChildNode.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ChildNode.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ChildNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..f08e2a9c1101a348bb0628046ba2cacd20490441
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ChildNode.java
@@ -0,0 +1,42 @@
+// 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;
+
+/**
+ * A node in the tree that has a parent and can notify it about changes.
+ *
+ * This class mostly serves as a convenience base class for implementations of {@link TreeNode}.
+ */
+public abstract class ChildNode implements TreeNode {
+ private final NodeParent mParent;
+
+ protected ChildNode(NodeParent parent) {
+ mParent = parent;
+ }
+
+ protected void notifyItemRangeChanged(int index, int count) {
+ mParent.onItemRangeChanged(this, index, count);
+ }
+
+ protected void notifyItemRangeInserted(int index, int count) {
+ mParent.onItemRangeInserted(this, index, count);
+ }
+
+ protected void notifyItemRangeRemoved(int index, int count) {
+ mParent.onItemRangeRemoved(this, index, count);
+ }
+
+ protected void notifyItemChanged(int index) {
+ notifyItemRangeChanged(index, 1);
+ }
+
+ protected void notifyItemInserted(int index) {
+ notifyItemRangeInserted(index, 1);
+ }
+
+ protected void notifyItemRemoved(int index) {
+ notifyItemRangeRemoved(index, 1);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698