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

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

Issue 2513453004: [Android NTP] Move suggestion sections into a separate node. (Closed)
Patch Set: sync Created 4 years 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/InnerNode.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/InnerNode.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/InnerNode.java
index acb5ed2f8be35fd7e73f24ec7cdd126040586c4e..fa3454bde6df003f45e56ec7c5f9a073d0a50f1d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/InnerNode.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/InnerNode.java
@@ -108,4 +108,34 @@ public abstract class InnerNode extends ChildNode implements NodeParent {
public void onItemRangeRemoved(TreeNode child, int index, int count) {
notifyItemRangeRemoved(getStartingOffsetForChild(child) + index, count);
}
+
+ @Override
+ public void init() {
+ super.init();
+ for (TreeNode child : getChildren()) {
+ child.init();
+ }
+ }
+
+ /**
+ * Helper method for adding a new child node. Notifies about the inserted items and initializes
+ * the child.
+ *
+ * @param child The child node to be added.
+ */
+ protected void didAddChild(TreeNode child) {
+ int count = child.getItemCount();
+ if (count > 0) onItemRangeInserted(child, 0, count);
+ child.init();
+ }
+
+ /**
+ * Helper method for removing a child node. Notifies about the removed items.
+ *
+ * @param child The child node to be removed.
+ */
+ protected void willRemoveChild(TreeNode child) {
+ int count = child.getItemCount();
+ if (count > 0) onItemRangeRemoved(child, 0, count);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698