@Override
 public boolean animateChange(
     RecyclerView.ViewHolder oldHolder,
     RecyclerView.ViewHolder newHolder,
     int fromX,
     int fromY,
     int toX,
     int toY) {
   if (oldHolder == newHolder) {
     // Don't know how to run change animations when the same view holder is re-used.
     // run a move animation to handle position changes.
     return animateMove(oldHolder, fromX, fromY, toX, toY);
   }
   final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
   final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
   final float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView);
   resetAnimation(oldHolder);
   int deltaX = (int) (toX - fromX - prevTranslationX);
   int deltaY = (int) (toY - fromY - prevTranslationY);
   // recover prev translation state after ending animation
   ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX);
   ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY);
   ViewCompat.setAlpha(oldHolder.itemView, prevAlpha);
   if (newHolder != null) {
     // carry over translation values
     resetAnimation(newHolder);
     ViewCompat.setTranslationX(newHolder.itemView, -deltaX);
     ViewCompat.setTranslationY(newHolder.itemView, -deltaY);
     ViewCompat.setAlpha(newHolder.itemView, 0);
   }
   mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
   return true;
 }
  @Override
  public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();

    if (position < -1) { // [-Infinity,-1)
      // This page is way off-screen to the left.
      ViewCompat.setAlpha(view, 0);

    } else if (position <= 0) { // [-1,0]
      // Use the default slide transition when moving to the left page
      ViewCompat.setAlpha(view, 1);
      ViewCompat.setTranslationX(view, 0);
      ViewCompat.setScaleX(view, 1);
      ViewCompat.setScaleY(view, 1);

    } else if (position <= 1) { // (0,1]
      // Fade the page out.
      ViewCompat.setAlpha(view, 1 - position);

      // Counteract the default slide transition
      ViewCompat.setTranslationX(view, pageWidth * -position);

      // Scale the page down (between MIN_SCALE and 1)
      float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
      ViewCompat.setScaleX(view, scaleFactor);
      ViewCompat.setScaleY(view, scaleFactor);

    } else { // (1,+Infinity]
      // This page is way off-screen to the right.
      ViewCompat.setAlpha(view, 0);
    }
  }
 public boolean animateAdd(RecyclerView.ViewHolder paramViewHolder)
 {
   endAnimation(paramViewHolder);
   ViewCompat.setAlpha(itemView, 0.0F);
   mPendingAdditions.add(paramViewHolder);
   return true;
 }
Ejemplo n.º 4
0
 @Override
 public boolean animateAdd(final ViewHolder holder) {
   endAnimation(holder);
   ViewCompat.setAlpha(holder.itemView, 0);
   mPendingAdditions.add(holder);
   return true;
 }
  public void setError(@Nullable CharSequence error) {
    if (!isErrorEnabled() && TextUtils.isEmpty(error)) {
      return;
    }

    if (!TextUtils.isEmpty(error)) {
      ViewCompat.setAlpha(this.error, 0f);
      setErrorEnabled(true);
      this.error.setText(error);

      ViewCompat.animate(this.error)
          .alpha(1f)
          .setDuration(200)
          .setInterpolator(ScopeStealing.INTERPOLATOR)
          .start();
    } else {
      if (isErrorEnabled()) {
        ViewCompat.animate(this.error)
            .alpha(1f)
            .setDuration(200)
            .setInterpolator(ScopeStealing.INTERPOLATOR)
            .setListener(
                new ViewPropertyAnimatorListenerAdapter() {
                  @Override
                  public void onAnimationEnd(View view) {
                    setErrorEnabled(false);
                  }
                })
            .start();
      }
    }
  }
Ejemplo n.º 6
0
 @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
 private void setAlpha(View view, int alpha) {
   if (view instanceof ImageView && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
     ((ImageView) view).setImageAlpha(alpha);
   } else {
     ViewCompat.setAlpha(view, alpha);
   }
 }
 @Override
 public boolean animateAdd(final RecyclerView.ViewHolder holder) {
   resetAnimation(holder);
   ViewCompat.setAlpha(holder.itemView, 0);
   prepareAnimateAdd(holder);
   mPendingAdditions.add(holder);
   return true;
 }
 public boolean animateChange(RecyclerView.ViewHolder paramViewHolder1, RecyclerView.ViewHolder paramViewHolder2, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
 {
   float f1 = ViewCompat.getTranslationX(itemView);
   float f2 = ViewCompat.getTranslationY(itemView);
   float f3 = ViewCompat.getAlpha(itemView);
   endAnimation(paramViewHolder1);
   int i = (int)(paramInt3 - paramInt1 - f1);
   int j = (int)(paramInt4 - paramInt2 - f2);
   ViewCompat.setTranslationX(itemView, f1);
   ViewCompat.setTranslationY(itemView, f2);
   ViewCompat.setAlpha(itemView, f3);
   if ((paramViewHolder2 != null) && (itemView != null))
   {
     endAnimation(paramViewHolder2);
     ViewCompat.setTranslationX(itemView, -i);
     ViewCompat.setTranslationY(itemView, -j);
     ViewCompat.setAlpha(itemView, 0.0F);
   }
   mPendingChanges.add(new DefaultItemAnimator.ChangeInfo(paramViewHolder1, paramViewHolder2, paramInt1, paramInt2, paramInt3, paramInt4, null));
   return true;
 }
Ejemplo n.º 9
0
 @Override
 public boolean animateChange(
     ViewHolder oldHolder, ViewHolder newHolder, int fromX, int fromY, int toX, int toY) {
   final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
   final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
   final float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView);
   endAnimation(oldHolder);
   int deltaX = (int) (toX - fromX - prevTranslationX);
   int deltaY = (int) (toY - fromY - prevTranslationY);
   // recover prev translation state after ending animation
   ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX);
   ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY);
   ViewCompat.setAlpha(oldHolder.itemView, prevAlpha);
   if (newHolder != null && newHolder.itemView != null) {
     // carry over translation values
     endAnimation(newHolder);
     ViewCompat.setTranslationX(newHolder.itemView, -deltaX);
     ViewCompat.setTranslationY(newHolder.itemView, -deltaY);
     ViewCompat.setAlpha(newHolder.itemView, 0);
   }
   mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
   return true;
 }
Ejemplo n.º 10
0
  private void animateAddImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mAddAnimations.add(holder);
    float startX, startY;

    int position = (int) view.getTag();

    if (position % 2 == 0) {
      startY = -100;
      startX = -width;
    } else {
      startY = 100;
      startX = width;
    }
    Log.d("test", String.valueOf(holder.getLayoutPosition()));
    ViewCompat.setTranslationX(view, startX);
    // 应该是相对偏移
    ViewCompat.setTranslationY(view, startY);
    ViewCompat.setAlpha(view, 0);
    animation.setInterpolator(new OvershootInterpolator());
    animation
        .alpha(1)
        .translationX(0)
        .translationY(0)
        .setDuration(getAddDuration())
        .setListener(
            new VpaListenerAdapter() {
              @Override
              public void onAnimationStart(View view) {
                dispatchAddStarting(holder);
              }

              @Override
              public void onAnimationCancel(View view) {
                ViewCompat.setAlpha(view, 1);
              }

              @Override
              public void onAnimationEnd(View view) {
                animation.setListener(null);
                dispatchAddFinished(holder);
                mAddAnimations.remove(holder);
                dispatchFinishedWhenDone();
                // 使用这个来复原
                ViewCompat.setTranslationY(view, 0);
              }
            })
        .start();
  }
Ejemplo n.º 11
0
 private boolean endChangeAnimationIfNecessary(ChangeInfo changeInfo, ViewHolder item) {
   boolean oldItem = false;
   if (changeInfo.newHolder == item) {
     changeInfo.newHolder = null;
   } else if (changeInfo.oldHolder == item) {
     changeInfo.oldHolder = null;
     oldItem = true;
   } else {
     return false;
   }
   ViewCompat.setAlpha(item.itemView, 1);
   ViewCompat.setTranslationX(item.itemView, 0);
   ViewCompat.setTranslationY(item.itemView, 0);
   dispatchChangeFinished(item, oldItem);
   return true;
 }
 private boolean endChangeAnimationIfNecessary(DefaultItemAnimator.ChangeInfo paramChangeInfo, RecyclerView.ViewHolder paramViewHolder)
 {
   boolean bool2 = false;
   boolean bool1 = false;
   if (newHolder == paramViewHolder) {
     newHolder = null;
   }
   for (;;)
   {
     ViewCompat.setAlpha(itemView, 1.0F);
     ViewCompat.setTranslationX(itemView, 0.0F);
     ViewCompat.setTranslationY(itemView, 0.0F);
     dispatchChangeFinished(paramViewHolder, bool1);
     bool1 = true;
     do
     {
       return bool1;
       bool1 = bool2;
     } while (oldHolder != paramViewHolder);
     oldHolder = null;
     bool1 = true;
   }
 }
 public RecyclerViewHolder setAlpha(int viewId, float value) {
   ViewCompat.setAlpha(findViewById(viewId), value);
   return this;
 }
  public void update(RecyclerView referenceList, float dx, float dy) {
    if (indexList != null && indexList.getChildCount() > 2) {
      show();
      updatePosBasedOnReferenceList(referenceList);

      View firstVisibleView = indexList.getChildAt(0);
      View secondVisibleView = indexList.getChildAt(1);

      TextView firstRowIndex = (TextView) firstVisibleView.findViewById(R.id.section_title);
      TextView secondRowIndex = (TextView) secondVisibleView.findViewById(R.id.section_title);

      int visibleRange = indexList.getChildCount();
      int actual = indexList.getChildPosition(firstVisibleView);
      int next = actual + 1;
      int last = actual + visibleRange;

      // RESET STICKY LETTER INDEX
      stickyIndex.setText(String.valueOf(getIndexContext(firstRowIndex)).toUpperCase());
      stickyIndex.setVisibility(TextView.VISIBLE);
      ViewCompat.setAlpha(firstRowIndex, 1);

      if (dy > 0) {
        // USER SCROLLING DOWN THE RecyclerView
        if (next <= last) {
          if (isHeader(firstRowIndex, secondRowIndex)) {
            stickyIndex.setVisibility(TextView.INVISIBLE);
            firstRowIndex.setVisibility(TextView.VISIBLE);
            ViewCompat.setAlpha(
                firstRowIndex,
                (1 - (Math.abs(ViewCompat.getY(firstVisibleView)) / firstRowIndex.getHeight())));
            secondRowIndex.setVisibility(TextView.VISIBLE);
          } else {
            firstRowIndex.setVisibility(TextView.INVISIBLE);
            stickyIndex.setVisibility(TextView.VISIBLE);
          }
        }
      } else if (dy < 0) {
        // USER IS SCROLLING UP THE RecyclerVIew
        if (next <= last) {
          // RESET FIRST ROW STATE
          firstRowIndex.setVisibility(TextView.INVISIBLE);
          if ((isHeader(firstRowIndex, secondRowIndex)
                  || (getIndexContext(firstRowIndex) != getIndexContext(secondRowIndex)))
              && isHeader(firstRowIndex, secondRowIndex)) {
            stickyIndex.setVisibility(TextView.INVISIBLE);
            firstRowIndex.setVisibility(TextView.VISIBLE);
            ViewCompat.setAlpha(
                firstRowIndex,
                1 - (Math.abs(ViewCompat.getY(firstVisibleView) / firstRowIndex.getHeight())));
            secondRowIndex.setVisibility(TextView.VISIBLE);
          } else {
            secondRowIndex.setVisibility(TextView.INVISIBLE);
          }
        }
      }

      if (stickyIndex.getVisibility() == TextView.VISIBLE) {
        firstRowIndex.setVisibility(TextView.INVISIBLE);
      }
    } else {
      hide();
    }
  }
 protected void preAnimateAdd(RecyclerView.ViewHolder holder) {
   super.preAnimateAdd(holder);
   ViewCompat.setAlpha(holder.itemView, 0);
   ViewCompat.setScaleX(holder.itemView, 1.5f);
   ViewCompat.setScaleY(holder.itemView, 1.5f);
 }
Ejemplo n.º 16
0
 public boolean animateAdd(RecyclerView.ViewHolder holder) {
   this.resetAnimation(holder);
   ViewCompat.setAlpha(holder.itemView, 0.0F);
   this.mPendingAdditions.add(holder);
   return true;
 }
 public void endAnimation(RecyclerView.ViewHolder paramViewHolder)
 {
   View localView = itemView;
   ViewCompat.animate(localView).cancel();
   int i = mPendingMoves.size() - 1;
   while (i >= 0)
   {
     if (mPendingMoves.get(i)).holder == paramViewHolder)
     {
       ViewCompat.setTranslationY(localView, 0.0F);
       ViewCompat.setTranslationX(localView, 0.0F);
       dispatchMoveFinished(paramViewHolder);
       mPendingMoves.remove(i);
     }
     i -= 1;
   }
   endChangeAnimation(mPendingChanges, paramViewHolder);
   if (mPendingRemovals.remove(paramViewHolder))
   {
     ViewCompat.setAlpha(localView, 1.0F);
     dispatchRemoveFinished(paramViewHolder);
   }
   if (mPendingAdditions.remove(paramViewHolder))
   {
     ViewCompat.setAlpha(localView, 1.0F);
     dispatchAddFinished(paramViewHolder);
   }
   i = mChangesList.size() - 1;
   ArrayList localArrayList;
   while (i >= 0)
   {
     localArrayList = (ArrayList)mChangesList.get(i);
     endChangeAnimation(localArrayList, paramViewHolder);
     if (localArrayList.isEmpty()) {
       mChangesList.remove(i);
     }
     i -= 1;
   }
   i = mMovesList.size() - 1;
   if (i >= 0)
   {
     localArrayList = (ArrayList)mMovesList.get(i);
     int j = localArrayList.size() - 1;
     for (;;)
     {
       if (j >= 0)
       {
         if (getholder != paramViewHolder) {
           break label293;
         }
         ViewCompat.setTranslationY(localView, 0.0F);
         ViewCompat.setTranslationX(localView, 0.0F);
         dispatchMoveFinished(paramViewHolder);
         localArrayList.remove(j);
         if (localArrayList.isEmpty()) {
           mMovesList.remove(i);
         }
       }
       i -= 1;
       break;
       label293:
       j -= 1;
     }
   }
   i = mAdditionsList.size() - 1;
   while (i >= 0)
   {
     localArrayList = (ArrayList)mAdditionsList.get(i);
     if (localArrayList.remove(paramViewHolder))
     {
       ViewCompat.setAlpha(localView, 1.0F);
       dispatchAddFinished(paramViewHolder);
       if (localArrayList.isEmpty()) {
         mAdditionsList.remove(i);
       }
     }
     i -= 1;
   }
   mRemoveAnimations.remove(paramViewHolder);
   mAddAnimations.remove(paramViewHolder);
   mChangeAnimations.remove(paramViewHolder);
   mMoveAnimations.remove(paramViewHolder);
   dispatchFinishedWhenDone();
 }
 @Override
 public void addAnimationPrepare(View view) {
   ViewCompat.setTranslationX(view, -view.getWidth());
   ViewCompat.setAlpha(view, 0);
 }
 @Override
 public void onSlideAmountUpdated(
     float horizontalAmount, float verticalAmount, boolean isSwiping) {
   float alpha = 1.0f - Math.min(Math.max(Math.abs(horizontalAmount), 0.0f), 1.0f);
   ViewCompat.setAlpha(mContainer, alpha);
 }
Ejemplo n.º 20
0
  @Override
  public void endAnimations() {
    int count = mPendingMoves.size();
    for (int i = count - 1; i >= 0; i--) {
      MoveInfo item = mPendingMoves.get(i);
      View view = item.holder.itemView;
      ViewCompat.setTranslationY(view, 0);
      ViewCompat.setTranslationX(view, 0);
      dispatchMoveFinished(item.holder);
      mPendingMoves.remove(i);
    }
    count = mPendingRemovals.size();
    for (int i = count - 1; i >= 0; i--) {
      ViewHolder item = mPendingRemovals.get(i);
      dispatchRemoveFinished(item);
      mPendingRemovals.remove(i);
    }
    count = mPendingAdditions.size();
    for (int i = count - 1; i >= 0; i--) {
      ViewHolder item = mPendingAdditions.get(i);
      View view = item.itemView;
      ViewCompat.setAlpha(view, 1);
      dispatchAddFinished(item);
      mPendingAdditions.remove(i);
    }
    count = mPendingChanges.size();
    for (int i = count - 1; i >= 0; i--) {
      endChangeAnimationIfNecessary(mPendingChanges.get(i));
    }
    mPendingChanges.clear();
    if (!isRunning()) {
      return;
    }

    int listCount = mMovesList.size();
    for (int i = listCount - 1; i >= 0; i--) {
      ArrayList<MoveInfo> moves = mMovesList.get(i);
      count = moves.size();
      for (int j = count - 1; j >= 0; j--) {
        MoveInfo moveInfo = moves.get(j);
        ViewHolder item = moveInfo.holder;
        View view = item.itemView;
        ViewCompat.setTranslationY(view, 0);
        ViewCompat.setTranslationX(view, 0);
        dispatchMoveFinished(moveInfo.holder);
        moves.remove(j);
        if (moves.isEmpty()) {
          mMovesList.remove(moves);
        }
      }
    }
    listCount = mAdditionsList.size();
    for (int i = listCount - 1; i >= 0; i--) {
      ArrayList<ViewHolder> additions = mAdditionsList.get(i);
      count = additions.size();
      for (int j = count - 1; j >= 0; j--) {
        ViewHolder item = additions.get(j);
        View view = item.itemView;
        ViewCompat.setAlpha(view, 1);
        dispatchAddFinished(item);
        additions.remove(j);
        if (additions.isEmpty()) {
          mAdditionsList.remove(additions);
        }
      }
    }
    listCount = mChangesList.size();
    for (int i = listCount - 1; i >= 0; i--) {
      ArrayList<ChangeInfo> changes = mChangesList.get(i);
      count = changes.size();
      for (int j = count - 1; j >= 0; j--) {
        endChangeAnimationIfNecessary(changes.get(j));
        if (changes.isEmpty()) {
          mChangesList.remove(changes);
        }
      }
    }

    cancelAll(mRemoveAnimations);
    cancelAll(mMoveAnimations);
    cancelAll(mAddAnimations);
    cancelAll(mChangeAnimations);

    dispatchAnimationsFinished();
  }
 @Override
 protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
   ViewCompat.setTranslationY(holder.itemView, -holder.itemView.getHeight());
   ViewCompat.setAlpha(holder.itemView, 0);
 }
 public void endAnimations()
 {
   int i = mPendingMoves.size() - 1;
   Object localObject1;
   Object localObject2;
   while (i >= 0)
   {
     localObject1 = (DefaultItemAnimator.MoveInfo)mPendingMoves.get(i);
     localObject2 = holder.itemView;
     ViewCompat.setTranslationY((View)localObject2, 0.0F);
     ViewCompat.setTranslationX((View)localObject2, 0.0F);
     dispatchMoveFinished(holder);
     mPendingMoves.remove(i);
     i -= 1;
   }
   i = mPendingRemovals.size() - 1;
   while (i >= 0)
   {
     dispatchRemoveFinished((RecyclerView.ViewHolder)mPendingRemovals.get(i));
     mPendingRemovals.remove(i);
     i -= 1;
   }
   i = mPendingAdditions.size() - 1;
   while (i >= 0)
   {
     localObject1 = (RecyclerView.ViewHolder)mPendingAdditions.get(i);
     ViewCompat.setAlpha(itemView, 1.0F);
     dispatchAddFinished((RecyclerView.ViewHolder)localObject1);
     mPendingAdditions.remove(i);
     i -= 1;
   }
   i = mPendingChanges.size() - 1;
   while (i >= 0)
   {
     endChangeAnimationIfNecessary((DefaultItemAnimator.ChangeInfo)mPendingChanges.get(i));
     i -= 1;
   }
   mPendingChanges.clear();
   if (!isRunning()) {
     return;
   }
   i = mMovesList.size() - 1;
   int j;
   while (i >= 0)
   {
     localObject1 = (ArrayList)mMovesList.get(i);
     j = ((ArrayList)localObject1).size() - 1;
     while (j >= 0)
     {
       localObject2 = (DefaultItemAnimator.MoveInfo)((ArrayList)localObject1).get(j);
       View localView = holder.itemView;
       ViewCompat.setTranslationY(localView, 0.0F);
       ViewCompat.setTranslationX(localView, 0.0F);
       dispatchMoveFinished(holder);
       ((ArrayList)localObject1).remove(j);
       if (((ArrayList)localObject1).isEmpty()) {
         mMovesList.remove(localObject1);
       }
       j -= 1;
     }
     i -= 1;
   }
   i = mAdditionsList.size() - 1;
   while (i >= 0)
   {
     localObject1 = (ArrayList)mAdditionsList.get(i);
     j = ((ArrayList)localObject1).size() - 1;
     while (j >= 0)
     {
       localObject2 = (RecyclerView.ViewHolder)((ArrayList)localObject1).get(j);
       ViewCompat.setAlpha(itemView, 1.0F);
       dispatchAddFinished((RecyclerView.ViewHolder)localObject2);
       ((ArrayList)localObject1).remove(j);
       if (((ArrayList)localObject1).isEmpty()) {
         mAdditionsList.remove(localObject1);
       }
       j -= 1;
     }
     i -= 1;
   }
   i = mChangesList.size() - 1;
   while (i >= 0)
   {
     localObject1 = (ArrayList)mChangesList.get(i);
     j = ((ArrayList)localObject1).size() - 1;
     while (j >= 0)
     {
       endChangeAnimationIfNecessary((DefaultItemAnimator.ChangeInfo)((ArrayList)localObject1).get(j));
       if (((ArrayList)localObject1).isEmpty()) {
         mChangesList.remove(localObject1);
       }
       j -= 1;
     }
     i -= 1;
   }
   cancelAll(mRemoveAnimations);
   cancelAll(mMoveAnimations);
   cancelAll(mAddAnimations);
   cancelAll(mChangeAnimations);
   dispatchAnimationsFinished();
 }
Ejemplo n.º 23
0
  @Override
  public void endAnimation(ViewHolder item) {
    final View view = item.itemView;
    // this will trigger end callback which should set properties to their
    // target values.
    ViewCompat.animate(view).cancel();
    // TODO if some other animations are chained to end, how do we cancel
    // them as well?
    for (int i = mPendingMoves.size() - 1; i >= 0; i--) {
      MoveInfo moveInfo = mPendingMoves.get(i);
      if (moveInfo.holder == item) {
        ViewCompat.setTranslationY(view, 0);
        ViewCompat.setTranslationX(view, 0);
        dispatchMoveFinished(item);
        mPendingMoves.remove(item);
      }
    }
    endChangeAnimation(mPendingChanges, item);
    if (mPendingRemovals.remove(item)) {
      ViewCompat.setAlpha(view, 1);
      dispatchRemoveFinished(item);
    }
    if (mPendingAdditions.remove(item)) {
      ViewCompat.setAlpha(view, 1);
      dispatchAddFinished(item);
    }

    for (int i = mChangesList.size() - 1; i >= 0; i--) {
      ArrayList<ChangeInfo> changes = mChangesList.get(i);
      endChangeAnimation(changes, item);
      if (changes.isEmpty()) {
        mChangesList.remove(changes);
      }
    }
    for (int i = mMovesList.size() - 1; i >= 0; i--) {
      ArrayList<MoveInfo> moves = mMovesList.get(i);
      for (int j = moves.size() - 1; j >= 0; j--) {
        MoveInfo moveInfo = moves.get(j);
        if (moveInfo.holder == item) {
          ViewCompat.setTranslationY(view, 0);
          ViewCompat.setTranslationX(view, 0);
          dispatchMoveFinished(item);
          moves.remove(j);
          if (moves.isEmpty()) {
            mMovesList.remove(moves);
          }
          break;
        }
      }
    }
    for (int i = mAdditionsList.size() - 1; i >= 0; i--) {
      ArrayList<ViewHolder> additions = mAdditionsList.get(i);
      if (additions.remove(item)) {
        ViewCompat.setAlpha(view, 1);
        dispatchAddFinished(item);
        if (additions.isEmpty()) {
          mAdditionsList.remove(additions);
        }
      }
    }

    // animations should be ended by the cancel above.
    if (mRemoveAnimations.remove(item) && DEBUG) {
      throw new IllegalStateException(
          "after animation is cancelled, item should not be in " + "mRemoveAnimations list");
    }

    if (mAddAnimations.remove(item) && DEBUG) {
      throw new IllegalStateException(
          "after animation is cancelled, item should not be in " + "mAddAnimations list");
    }

    if (mChangeAnimations.remove(item) && DEBUG) {
      throw new IllegalStateException(
          "after animation is cancelled, item should not be in " + "mChangeAnimations list");
    }

    if (mMoveAnimations.remove(item) && DEBUG) {
      throw new IllegalStateException(
          "after animation is cancelled, item should not be in " + "mMoveAnimations list");
    }
    dispatchFinishedWhenDone();
  }
 @Override
 public void removeAnimationCleanup(View view) {
   ViewCompat.setTranslationX(view, 0);
   ViewCompat.setAlpha(view, 1);
 }
Ejemplo n.º 25
0
 @Override
 protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
   ViewCompat.setAlpha(holder.itemView, 0);
 }
 @Override
 public void onViewRecycled(MyViewHolder holder) {
   super.onViewRecycled(holder);
   ViewCompat.setAlpha(holder.mContainer, 1.0f);
 }