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

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

Issue 2520443002: Make AllDismissedItem and Footer optional leaves. (Closed)
Patch Set: comments Created 4 years, 1 month 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/NewTabPageAdapter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java
index df6717641940152b74619e711a542100510c6f0d..00a3a2ebca0a7d4a4b470a9af769b5339a4650d0 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java
@@ -60,8 +60,8 @@ public class NewTabPageAdapter
private final List<TreeNode> mChildren = new ArrayList<>();
private final AboveTheFoldItem mAboveTheFold = new AboveTheFoldItem();
private final SignInPromo mSigninPromo;
- private final AllDismissedItem mAllDismissed = new AllDismissedItem();
- private final Footer mFooter = new Footer();
+ private final AllDismissedItem mAllDismissed;
+ private final Footer mFooter;
private final SpacingItem mBottomSpacer = new SpacingItem();
private final InnerNode mRoot;
@@ -171,6 +171,8 @@ public class NewTabPageAdapter
};
mSigninPromo = new SignInPromo(mRoot, this);
+ mAllDismissed = new AllDismissedItem(mRoot);
+ mFooter = new Footer(mRoot);
DestructionObserver signInObserver = mSigninPromo.getObserver();
if (signInObserver != null) mNewTabPageManager.addDestructionObserver(signInObserver);
@@ -424,9 +426,12 @@ public class NewTabPageAdapter
mChildren.add(mAboveTheFold);
mChildren.addAll(mSections.values());
mChildren.add(mSigninPromo);
- mChildren.add(hasAllBeenDismissed() ? mAllDismissed : mFooter);
+ mChildren.add(mAllDismissed);
+ mChildren.add(mFooter);
mChildren.add(mBottomSpacer);
+ updateAllDismissedVisibility();
+
// TODO(mvanouwerkerk): Notify about the subset of changed items. At least |mAboveTheFold|
// has not changed when refreshing from the all dismissed state.
notifyDataSetChanged();
@@ -434,16 +439,8 @@ public class NewTabPageAdapter
private void updateAllDismissedVisibility() {
boolean showAllDismissed = hasAllBeenDismissed();
- if (showAllDismissed == mChildren.contains(mAllDismissed)) return;
-
- if (showAllDismissed) {
- assert mChildren.contains(mFooter);
- mChildren.set(mChildren.indexOf(mFooter), mAllDismissed);
- } else {
- assert mChildren.contains(mAllDismissed);
- mChildren.set(mChildren.indexOf(mAllDismissed), mFooter);
- }
- notifyItemChanged(getLastContentItemPosition());
+ mAllDismissed.setVisible(showAllDismissed);
+ mFooter.setVisible(!showAllDismissed);
}
private void removeSection(SuggestionsSection section) {

Powered by Google App Engine
This is Rietveld 408576698