Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java |
| index b1d3779bd2489a4c7ff8b07cc465c3f3193f1702..5d67d20679a11d784d414ca953aba6fb9a6f9e6b 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java |
| @@ -6,6 +6,7 @@ package org.chromium.chrome.browser.ntp; |
| import android.content.Context; |
| import android.content.res.Resources; |
| +import android.support.v7.widget.RecyclerView; |
| import android.util.AttributeSet; |
| import android.view.View; |
| import android.widget.LinearLayout; |
| @@ -34,6 +35,7 @@ public class NewTabPageLayout extends LinearLayout { |
| private int mParentScrollViewportHeight; |
| + private boolean mUseCardsUiEnabled; |
|
Bernhard Bauer
2016/05/05 18:04:40
Nit: I would call this either |mUseCardsUi| or |mC
mcwilliams
2016/05/05 18:21:11
Done.
|
| private View mTopSpacer; |
| private View mMiddleSpacer; |
| private View mBottomSpacer; |
| @@ -82,10 +84,32 @@ public class NewTabPageLayout extends LinearLayout { |
| mParentScrollViewportHeight = height; |
| } |
| + /** |
| + * |
|
Bernhard Bauer
2016/05/05 18:04:40
Javadoc please.
mcwilliams
2016/05/05 18:21:11
:)
|
| + */ |
| + public void setUseCardsUiEnabled(boolean useCardsUi) { |
| + mUseCardsUiEnabled = useCardsUi; |
| + } |
| + |
| @Override |
| protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| mScrollCompensationSpacer.getLayoutParams().height = 0; |
| super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| + |
| + // Check if we are showing snippets. If Most Likely is fully rendered on the initial page |
| + // load and has enough space for the peeking card, push snippets to the bottom of the page |
| + // to show the peeking card. |
| + if (mUseCardsUiEnabled) { |
| + int peekingCardHeight = getContext().getResources().getDimensionPixelSize( |
| + R.dimen.snippets_padding_and_peeking_card_height); |
| + if (mParentScrollViewportHeight >= getMeasuredHeight() + peekingCardHeight) { |
| + RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) getLayoutParams(); |
| + params.height = mParentScrollViewportHeight - peekingCardHeight; |
| + } |
| + } |
| + // TODO(https://crbug.com/609487): Push snippets below the fold when most likely |
| + // is not fully rendered. |
| + |
| distributeExtraSpace(mTopSpacer.getMeasuredHeight()); |
| int minScrollAmountRequired = 0; |