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

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

Issue 2144413003: NTP, peeking card and heading hiding constraints (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes Created 4 years, 5 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/CardViewHolder.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java
index c5a2ef4e8e4ba590433cc31f6878ceba029fb3b4..f45eb14d1c7139e11ee8df8297b226937886bb35 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java
@@ -127,11 +127,23 @@ public class CardViewHolder extends NewTabPageViewHolder {
viewportHeight - mMaxPeekPadding - itemView.getTop(), 0, mMaxPeekPadding));
}
- /** Returns whether the card is currently peeking. */
+ /**
+ * @return Whether the card is peeking.
+ */
public boolean isPeeking() {
return mPeekPadding < mMaxPeekPadding;
}
+ /**
+ * @return Whether the card can peek.
+ */
+ public boolean canPeek() {
+ // Only allow the card to peek if the user has not scrolled on the page beyond the
+ // |mMaxPeekPadding| height. There will only ever be one peeking card on the page and only
+ // when there is enough space to show the peeking card on the first screen at the bottom.
+ return mRecyclerView.computeVerticalScrollOffset() <= itemView.getHeight();
+ }
+
@Override
public void updateViewStateForDismiss(float dX) {
float input = Math.abs(dX) / itemView.getMeasuredWidth();
@@ -148,7 +160,7 @@ public class CardViewHolder extends NewTabPageViewHolder {
private void setPeekingStateForPadding(int padding) {
// TODO(mcwilliams): Change the 'padding' value to a percentage of what the transition
// should be which can be used for alpha and bleed.
- mPeekPadding = padding;
+ mPeekPadding = canPeek() ? padding : mMaxPeekPadding;
// Modify the padding so as the margin increases, the padding decreases, keeping the card's
// contents in the same position. The top and bottom remain the same.

Powered by Google App Engine
This is Rietveld 408576698