| 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 6ebfa32e3979655cdf2c64d1290738bf18c79eea..1db039439303053043116bb0c0557a051b9ac763 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
|
| @@ -483,9 +483,7 @@ public class NewTabPageRecyclerView extends RecyclerView implements TouchDisable
|
| * in {@link CardViewHolder#onBindViewHolder()}.
|
| */
|
| public void dismissItemWithAnimation(final ViewHolder viewHolder) {
|
| - // We need to check the position, as the view holder might have been removed.
|
| - final int position = viewHolder.getAdapterPosition();
|
| - if (position == RecyclerView.NO_POSITION) {
|
| + if (viewHolder.getAdapterPosition() == RecyclerView.NO_POSITION) {
|
| // The item does not exist anymore, so ignore.
|
| return;
|
| }
|
| @@ -513,13 +511,23 @@ public class NewTabPageRecyclerView extends RecyclerView implements TouchDisable
|
|
|
| @Override
|
| public void onAnimationEnd(Animator animation) {
|
| - getNewTabPageAdapter().dismissItem(position);
|
| + dismissItemInternal(viewHolder);
|
| NewTabPageRecyclerView.this.onItemDismissFinished(viewHolder);
|
| }
|
| });
|
| animation.start();
|
| }
|
|
|
| + private void dismissItemInternal(ViewHolder viewHolder) {
|
| + // Re-check the position in case the adapter has changed.
|
| + final int position = viewHolder.getAdapterPosition();
|
| + if (position == RecyclerView.NO_POSITION) {
|
| + // The item does not exist anymore, so ignore.
|
| + return;
|
| + }
|
| + getNewTabPageAdapter().dismissItem(position);
|
| + }
|
| +
|
| /**
|
| * @param animations in/out list holding the animators to play.
|
| * @param view view to animate.
|
|
|