OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.ntp.cards; | 5 package org.chromium.chrome.browser.ntp.cards; |
6 | 6 |
7 import android.animation.Animator; | 7 import android.animation.Animator; |
8 import android.animation.AnimatorListenerAdapter; | 8 import android.animation.AnimatorListenerAdapter; |
9 import android.animation.AnimatorSet; | 9 import android.animation.AnimatorSet; |
10 import android.animation.ObjectAnimator; | 10 import android.animation.ObjectAnimator; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 /** | 167 /** |
168 * Updates the space added at the end of the list to make sure the above/bel
ow the fold | 168 * Updates the space added at the end of the list to make sure the above/bel
ow the fold |
169 * distinction can be preserved. | 169 * distinction can be preserved. |
170 */ | 170 */ |
171 public void refreshBottomSpacing() { | 171 public void refreshBottomSpacing() { |
172 ViewHolder bottomSpacingViewHolder = findBottomSpacer(); | 172 ViewHolder bottomSpacingViewHolder = findBottomSpacer(); |
173 | 173 |
174 // It might not be in the layout yet if it's not visible or ready to be
displayed. | 174 // It might not be in the layout yet if it's not visible or ready to be
displayed. |
175 if (bottomSpacingViewHolder == null) return; | 175 if (bottomSpacingViewHolder == null) return; |
176 | 176 |
177 assert bottomSpacingViewHolder.getItemViewType() == NewTabPageItem.VIEW_
TYPE_SPACING; | 177 assert bottomSpacingViewHolder.getItemViewType() == ItemViewType.SPACING
; |
178 bottomSpacingViewHolder.itemView.requestLayout(); | 178 bottomSpacingViewHolder.itemView.requestLayout(); |
179 } | 179 } |
180 | 180 |
181 /** | 181 /** |
182 * Calculates the height of the bottom spacing item, such that there is alwa
ys enough content | 182 * Calculates the height of the bottom spacing item, such that there is alwa
ys enough content |
183 * below the fold to push the header up to to the top of the screen. | 183 * below the fold to push the header up to to the top of the screen. |
184 */ | 184 */ |
185 int calculateBottomSpacing() { | 185 int calculateBottomSpacing() { |
186 int aboveTheFoldPosition = getNewTabPageAdapter().getAboveTheFoldPositio
n(); | 186 int aboveTheFoldPosition = getNewTabPageAdapter().getAboveTheFoldPositio
n(); |
187 int firstVisiblePos = mLayoutManager.findFirstVisibleItemPosition(); | 187 int firstVisiblePos = mLayoutManager.findFirstVisibleItemPosition(); |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 public void updateViewStateForDismiss(float dX, ViewHolder viewHolder) { | 517 public void updateViewStateForDismiss(float dX, ViewHolder viewHolder) { |
518 if (!((NewTabPageViewHolder) viewHolder).isDismissable()) return; | 518 if (!((NewTabPageViewHolder) viewHolder).isDismissable()) return; |
519 | 519 |
520 viewHolder.itemView.setTranslationX(dX); | 520 viewHolder.itemView.setTranslationX(dX); |
521 | 521 |
522 float input = Math.abs(dX) / viewHolder.itemView.getMeasuredWidth(); | 522 float input = Math.abs(dX) / viewHolder.itemView.getMeasuredWidth(); |
523 float alpha = 1 - DISMISS_INTERPOLATOR.getInterpolation(input); | 523 float alpha = 1 - DISMISS_INTERPOLATOR.getInterpolation(input); |
524 viewHolder.itemView.setAlpha(alpha); | 524 viewHolder.itemView.setAlpha(alpha); |
525 } | 525 } |
526 } | 526 } |
OLD | NEW |