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

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

Issue 2400783003: Ntp: show AllDismissedItem when all sections have been dismissed. (Closed)
Patch Set: 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/NewTabPageRecyclerView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageRecyclerView.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageRecyclerView.java
index 56073eb873ebab2a771b054d55267835a6a1170f..a7ee607f2844848607cca892436e26629e2759cc 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageRecyclerView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageRecyclerView.java
@@ -193,11 +193,11 @@ public class NewTabPageRecyclerView extends RecyclerView {
return 0;
}
- ViewHolder lastContentItem = findLastContentItem();
+ ViewHolder spacer = findBottomSpacer();
ViewHolder aboveTheFold = findViewHolderForAdapterPosition(aboveTheFoldPosition);
int bottomSpacing = getHeight() - mToolbarHeight;
- if (lastContentItem == null || aboveTheFold == null) {
+ if (spacer == null || aboveTheFold == null) {
// This can happen in several cases, where some elements are not visible and the
// RecyclerView didn't already attach them. We handle it by just adding space to make
// sure that we never run out and force the UI to jump around and get stuck in a
@@ -205,17 +205,16 @@ public class NewTabPageRecyclerView extends RecyclerView {
// next pass. Known cases that make it necessary:
// - The card list is refreshed while the NTP is not shown, for example when changing
// the sync settings.
- // - Dismissing a snippet and having the status card coming to take its place.
+ // - Dismissing a suggestion and having the status card coming to take its place.
// - Refresh while being below the fold, for example by tapping the status card.
if (aboveTheFold != null) bottomSpacing -= aboveTheFold.itemView.getBottom();
Log.w(TAG, "The RecyclerView items are not attached, can't determine the content "
- + "height: snap=%s, last=%s. Using full height: %d ",
- aboveTheFold, lastContentItem, bottomSpacing);
+ + "height: snap=%s, spacer=%s. Using full height: %d ",
+ aboveTheFold, spacer, bottomSpacing);
} else {
- int contentHeight =
- lastContentItem.itemView.getBottom() - aboveTheFold.itemView.getBottom();
+ int contentHeight = spacer.itemView.getTop() - aboveTheFold.itemView.getBottom();
bottomSpacing -= contentHeight - mCompensationHeight;
}
@@ -302,49 +301,35 @@ public class NewTabPageRecyclerView extends RecyclerView {
* @return The {@code ViewHolder} for the first card, or null if it is not present.
*/
private CardViewHolder findFirstCard() {
- int firstCardPosition = getNewTabPageAdapter().getFirstCardPosition();
- if (firstCardPosition == RecyclerView.NO_POSITION) return null;
+ int position = getNewTabPageAdapter().getFirstCardPosition();
+ if (position == RecyclerView.NO_POSITION) return null;
- ViewHolder viewHolder = findViewHolderForAdapterPosition(firstCardPosition);
+ ViewHolder viewHolder = findViewHolderForAdapterPosition(position);
if (!(viewHolder instanceof CardViewHolder)) return null;
return (CardViewHolder) viewHolder;
}
/**
- * Finds the view holder for the last content item: the footer.
- * @return The {@code ViewHolder} of the last content item, or null if it is not present.
- */
- private ViewHolder findLastContentItem() {
- int lastContentItemPosition = getNewTabPageAdapter().getLastContentItemPosition();
- if (lastContentItemPosition == RecyclerView.NO_POSITION) return null;
-
- ViewHolder viewHolder = findViewHolderForAdapterPosition(lastContentItemPosition);
- if (viewHolder instanceof Footer.ViewHolder) return viewHolder;
-
- return null;
- }
-
- /**
* Finds the view holder for the bottom spacer.
* @return The {@code ViewHolder} of the bottom spacer, or null if it is not present.
*/
private ViewHolder findBottomSpacer() {
- int bottomSpacerPosition = getNewTabPageAdapter().getBottomSpacerPosition();
- if (bottomSpacerPosition == RecyclerView.NO_POSITION) return null;
+ int position = getNewTabPageAdapter().getBottomSpacerPosition();
+ if (position == RecyclerView.NO_POSITION) return null;
- return findViewHolderForAdapterPosition(bottomSpacerPosition);
+ return findViewHolderForAdapterPosition(position);
}
/**
* Finds the above the fold view.
- * @return The View for above the fold or null, if it is not present.
+ * @return The view for above the fold or null, if it is not present.
*/
public NewTabPageLayout findAboveTheFoldView() {
- int aboveTheFoldPosition = getNewTabPageAdapter().getAboveTheFoldPosition();
- if (aboveTheFoldPosition == RecyclerView.NO_POSITION) return null;
+ int position = getNewTabPageAdapter().getAboveTheFoldPosition();
+ if (position == RecyclerView.NO_POSITION) return null;
- ViewHolder viewHolder = findViewHolderForAdapterPosition(aboveTheFoldPosition);
+ ViewHolder viewHolder = findViewHolderForAdapterPosition(position);
if (viewHolder == null) return null;
View view = viewHolder.itemView;

Powered by Google App Engine
This is Rietveld 408576698