Chromium Code Reviews| 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 ef1261d99e1c438c3fe73ab98dff582d0cb0daf7..d3e4d3c97bafa3b93e38facc331a057f60f99c05 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 |
| @@ -33,7 +33,9 @@ |
| import org.chromium.chrome.browser.preferences.ChromePreferenceManager; |
| import org.chromium.chrome.browser.util.ViewUtils; |
| +import java.util.ArrayList; |
| import java.util.HashMap; |
| +import java.util.List; |
| import java.util.Map; |
| /** |
| @@ -485,33 +487,35 @@ public boolean gatherTransparentRegion(Region region) { |
| * the animation here should be reflected also in |
| * {@link #updateViewStateForDismiss(float, ViewHolder)} and reset in |
| * {@link CardViewHolder#onBindViewHolder()}. |
| - * @param suggestion The item to be dismissed. |
| + * @param item The item to be dismissed. |
| */ |
| - public void dismissItemWithAnimation(SnippetArticle suggestion) { |
| - // We need to recompute the position, as it might have changed. |
| - final int position = getNewTabPageAdapter().getSuggestionPosition(suggestion); |
|
dgn
2016/11/10 19:44:02
problem1: this does not support things that are no
|
| + public void dismissItemWithAnimation(final ViewHolder viewHolder) { |
| + // We need to recompute the position, as it might have changed. ??? |
| + final int position = viewHolder.getAdapterPosition(); |
| if (position == RecyclerView.NO_POSITION) { |
| // The item does not exist anymore, so ignore. |
| return; |
| } |
| - final View itemView = mLayoutManager.findViewByPosition(position); |
| - if (itemView == null) { |
| - // The view is not visible anymore, skip the animation. |
| - getNewTabPageAdapter().dismissItem(position); |
| - return; |
| - } |
| - |
| - final ViewHolder viewHolder = getChildViewHolder(itemView); |
| if (!((NewTabPageViewHolder) viewHolder).isDismissable()) { |
| // The item is not dismissable (anymore), so ignore. |
| return; |
| } |
| - AnimatorSet animation = new AnimatorSet(); |
| - animation.playTogether(ObjectAnimator.ofFloat(itemView, View.ALPHA, 0f), |
| + List<Animator> animations = new ArrayList<>(); |
| + animations.add(ObjectAnimator.ofFloat(itemView, View.ALPHA, 0f)); |
| + animations.add( |
| ObjectAnimator.ofFloat(itemView, View.TRANSLATION_X, (float) itemView.getWidth())); |
| + final ViewHolder dismissSibling = getNewTabPageAdapter().getDismissSibling(viewHolder); |
| + if (dismissSibling != null) { |
| + animations.add(ObjectAnimator.ofFloat(dismissSibling.itemView, View.ALPHA, 0f)); |
| + animations.add(ObjectAnimator.ofFloat( |
| + dismissSibling.itemView, View.TRANSLATION_X, (float) itemView.getWidth())); |
| + } |
| + |
| + AnimatorSet animation = new AnimatorSet(); |
| + animation.playTogether(animations.toArray(new Animator[animations.size()])); |
| animation.setDuration(DISMISS_ANIMATION_TIME_MS); |
| animation.setInterpolator(DISMISS_INTERPOLATOR); |
| animation.addListener(new AnimatorListenerAdapter() { |