@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;
 }
 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;
 }
Exemplo n.º 3
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;
 }
  private boolean intersectVisibleToUser(Rect rect) {
    if (rect == null || rect.isEmpty()) {
      return false;
    }
    if (mView.getWindowVisibility() != 0) {
      return false;
    }
    Object obj;
    for (obj = mView.getParent(); obj instanceof View; obj = ((View) (obj)).getParent()) {
      obj = (View) obj;
      if (ViewCompat.getAlpha(((View) (obj))) <= 0.0F || ((View) (obj)).getVisibility() != 0) {
        return false;
      }
    }

    if (obj == null) {
      return false;
    }
    if (!mView.getLocalVisibleRect(mTempVisibleRect)) {
      return false;
    } else {
      return rect.intersect(mTempVisibleRect);
    }
  }