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

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

Issue 2415663006: 📰 Fix the calculation of the height of the bottom spacer (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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b0c46c378111f840052f583fa1543a9d1a58623e..34442a74d5f0f63709563899de6c6c9ee1643694 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
@@ -195,11 +195,11 @@ int calculateBottomSpacing() {
return 0;
}
- ViewHolder spacer = findBottomSpacer();
+ ViewHolder lastContentItem = findLastContentItem();
ViewHolder aboveTheFold = findViewHolderForAdapterPosition(aboveTheFoldPosition);
int bottomSpacing = getHeight() - mToolbarHeight;
- if (spacer == null || aboveTheFold == null) {
+ if (lastContentItem == 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
@@ -214,9 +214,10 @@ int calculateBottomSpacing() {
Log.w(TAG, "The RecyclerView items are not attached, can't determine the content "
+ "height: snap=%s, spacer=%s. Using full height: %d ",
- aboveTheFold, spacer, bottomSpacing);
+ aboveTheFold, lastContentItem, bottomSpacing);
} else {
- int contentHeight = spacer.itemView.getTop() - aboveTheFold.itemView.getBottom();
+ int contentHeight =
+ lastContentItem.itemView.getBottom() - aboveTheFold.itemView.getBottom();
bottomSpacing -= contentHeight - mCompensationHeight;
}
@@ -323,6 +324,13 @@ private ViewHolder findBottomSpacer() {
return findViewHolderForAdapterPosition(position);
}
+ private ViewHolder findLastContentItem() {
+ int position = getNewTabPageAdapter().getLastContentItemPosition();
+ if (position == RecyclerView.NO_POSITION) return null;
+
+ return findViewHolderForAdapterPosition(position);
+ }
+
/**
* Finds the above the fold view.
* @return The view for above the fold or null, if it is not present.
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698