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

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

Issue 1955823002: Fade the peeking card content is as the user is scrolling down (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | 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/NewTabPageView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
index 939c2d38d5920012c76e1bffebc705787f1c40c4..cfa1030177570384a6db81e49f2049e6595408dd 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
@@ -449,18 +449,19 @@ public class NewTabPageView extends FrameLayout
*/
private void updatePeekingCard() {
// Get the first snippet that could display to make the peeking card transition.
- View firstSnippetView = null;
+ ViewGroup firstSnippet = null;
int adapterSize = mNewTabPageAdapter.getItemCount();
for (int i = 0; i < adapterSize; i++) {
if (mNewTabPageAdapter.getItemViewType(i) == NewTabPageListItem.VIEW_TYPE_SNIPPET) {
- firstSnippetView = mRecyclerView.getLayoutManager().findViewByPosition(i);
+ firstSnippet =
+ (ViewGroup) mRecyclerView.getLayoutManager().findViewByPosition(i);
break;
}
}
// If first snippet exists change the parameters from peeking card with bleed to full page
// card when scrolling.
- if (firstSnippetView != null && firstSnippetView.isShown()) {
+ if (firstSnippet != null && firstSnippet.isShown()) {
// Value used for max peeking card height and padding.
int maxPadding = getResources().getDimensionPixelSize(
R.dimen.snippets_padding_and_peeking_card_height);
@@ -475,14 +476,21 @@ public class NewTabPageView extends FrameLayout
// Modify the padding so as the margin increases, the padding decreases so the cards
// content does not shift. Top and bottom remain the same.
- firstSnippetView.setPadding(
+ firstSnippet.setPadding(
maxPadding - bleed, maxPadding, maxPadding - bleed, maxPadding);
// Modify the margin to grow the card from bleed to full width.
RecyclerView.LayoutParams params =
- (RecyclerView.LayoutParams) firstSnippetView.getLayoutParams();
+ (RecyclerView.LayoutParams) firstSnippet.getLayoutParams();
params.leftMargin = bleed;
params.rightMargin = bleed;
+
+ // Set the opacity of the card content to be 0 when peeking and 1 when full width.
+ int firstSnippetChildCount = firstSnippet.getChildCount();
+ for (int i = 0; i < firstSnippetChildCount; ++i) {
+ View snippetChild = firstSnippet.getChildAt(i);
+ snippetChild.setAlpha((maxPadding - bleed) / (float) maxPadding);
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698