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

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

Issue 2617133002: [Android NTP] Move more of the dismissal logic into the tree. (Closed)
Patch Set: annotation Created 3 years, 11 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/OptionalLeaf.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/OptionalLeaf.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/OptionalLeaf.java
index fe95e48e7e90c380b6cdbf1ddee706011752f1a6..0cad55604f3771dbf850cc1f7448669a3f13136b 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/OptionalLeaf.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/OptionalLeaf.java
@@ -9,6 +9,9 @@ import android.support.annotation.CallSuper;
import org.chromium.base.Callback;
import org.chromium.chrome.browser.ntp.snippets.SnippetArticle;
+import java.util.Collections;
+import java.util.Set;
+
/**
* An optional leaf (i.e. single item) in the tree. Depending on its internal state (see
* {@link #isVisible()}), the item will be present or absent from the tree, by manipulating the
@@ -44,15 +47,15 @@ public abstract class OptionalLeaf extends ChildNode {
}
@Override
- public void dismissItem(int position, Callback<String> itemRemovedCallback) {
+ public Set<Integer> getItemDismissalGroup(int position) {
checkIndex(position);
- dismiss(itemRemovedCallback);
+ return canBeDismissed() ? Collections.singleton(0) : Collections.<Integer>emptySet();
}
@Override
- public int getDismissSiblingPosDelta(int position) {
+ public void dismissItem(int position, Callback<String> itemRemovedCallback) {
checkIndex(position);
- return 0;
+ dismiss(itemRemovedCallback);
}
/** @return Whether the optional item is currently visible. */
@@ -93,6 +96,13 @@ public abstract class OptionalLeaf extends ChildNode {
protected abstract int getItemViewType();
/**
+ * @return Whether the item can be dismissed.
+ */
+ protected boolean canBeDismissed() {
+ return false;
+ }
+
+ /**
* Dismiss this item. The default implementation asserts, as by default items can't be
* dismissed.
* @param itemRemovedCallback Should be called with the title of the dismissed item, to announce

Powered by Google App Engine
This is Rietveld 408576698