Exemplo n.º 1
0
        public override bool animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder, int fromX, int fromY, int toX, int toY)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final float prevTranslationX = android.support.v4.view.ViewCompat.getTranslationX(oldHolder.itemView);
            float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final float prevTranslationY = android.support.v4.view.ViewCompat.getTranslationY(oldHolder.itemView);
            float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final float prevAlpha = android.support.v4.view.ViewCompat.getAlpha(oldHolder.itemView);
            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 && newHolder.itemView != 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);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: @Override public boolean animateMove(final android.support.v7.widget.RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY)
        public override bool animateMove(RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.view.View view = holder.itemView;
            View view = holder.itemView;

            fromX += ViewCompat.getTranslationX(holder.itemView);
            fromY += ViewCompat.getTranslationY(holder.itemView);
            resetAnimation(holder);
            int deltaX = toX - fromX;
            int deltaY = toY - fromY;

            if (deltaX == 0 && deltaY == 0)
            {
                dispatchMoveFinished(holder);
                return(false);
            }
            if (deltaX != 0)
            {
                ViewCompat.setTranslationX(view, -deltaX);
            }
            if (deltaY != 0)
            {
                ViewCompat.setTranslationY(view, -deltaY);
            }
            mPendingMoves.Add(new MoveInfo(holder, fromX, fromY, toX, toY));
            return(true);
        }