OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.ntp.cards; | 5 package org.chromium.chrome.browser.ntp.cards; |
6 | 6 |
7 import org.chromium.chrome.browser.ntp.snippets.SnippetArticle; | 7 import org.chromium.chrome.browser.ntp.snippets.SnippetArticle; |
8 | 8 |
9 import java.util.List; | 9 import java.util.List; |
10 | 10 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 @Override | 102 @Override |
103 public void onItemRangeInserted(TreeNode child, int index, int count) { | 103 public void onItemRangeInserted(TreeNode child, int index, int count) { |
104 notifyItemRangeInserted(getStartingOffsetForChild(child) + index, count)
; | 104 notifyItemRangeInserted(getStartingOffsetForChild(child) + index, count)
; |
105 } | 105 } |
106 | 106 |
107 @Override | 107 @Override |
108 public void onItemRangeRemoved(TreeNode child, int index, int count) { | 108 public void onItemRangeRemoved(TreeNode child, int index, int count) { |
109 notifyItemRangeRemoved(getStartingOffsetForChild(child) + index, count); | 109 notifyItemRangeRemoved(getStartingOffsetForChild(child) + index, count); |
110 } | 110 } |
| 111 |
| 112 @Override |
| 113 public void init() { |
| 114 super.init(); |
| 115 for (TreeNode child : getChildren()) { |
| 116 child.init(); |
| 117 } |
| 118 } |
| 119 |
| 120 /** |
| 121 * Helper method for adding a new child node. Notifies about the inserted it
ems and initializes |
| 122 * the child. |
| 123 * |
| 124 * @param child The child node to be added. |
| 125 */ |
| 126 protected void didAddChild(TreeNode child) { |
| 127 int count = child.getItemCount(); |
| 128 if (count > 0) onItemRangeInserted(child, 0, count); |
| 129 child.init(); |
| 130 } |
| 131 |
| 132 /** |
| 133 * Helper method for removing a child node. Notifies about the removed items
. |
| 134 * |
| 135 * @param child The child node to be removed. |
| 136 */ |
| 137 protected void willRemoveChild(TreeNode child) { |
| 138 int count = child.getItemCount(); |
| 139 if (count > 0) onItemRangeRemoved(child, 0, count); |
| 140 } |
111 } | 141 } |
OLD | NEW |