コード例 #1
0
        public override void RunPendingAnimations()
        {
            bool removalsPending  = !mPendingRemovals.isEmpty();
            bool movesPending     = !mPendingMoves.isEmpty();
            bool additionsPending = !mPendingAdditions.isEmpty();

            if (!removalsPending && !movesPending && !additionsPending)
            {
                // nothing to animate
                return;
            }
            // First, remove stuff
            foreach (RecyclerView.ViewHolder holder in mPendingRemovals)
            {
                animateRemoveImpl(holder);
            }
            mPendingRemovals.clear();
            // Next, move stuff
            if (movesPending)
            {
                mMoves.addAll(mPendingMoves);
                mPendingMoves.clear();
                Runnable mover = new Runnable();
//				mover. {
//					@Override
//					public void run() {
//						for (MoveInfo moveInfo : mMoves) {
//							animateMoveImpl(moveInfo.holder, moveInfo.fromX, moveInfo.fromY,
//								moveInfo.toX, moveInfo.toY);
//						}
//						mMoves.clear();
//					}
//				};
                if (removalsPending)
                {
                    View view = mMoves.get(0).holder.itemView;
                    ViewCompat.postOnAnimationDelayed(view, mover, getRemoveDuration());
                }
                else
                {
                    mover.run();
                }
            }
            // Next, add stuff
            if (additionsPending)
            {
                mAdditions.addAll(mPendingAdditions);
                mPendingAdditions.clear();
                Runnable adder = new Runnable();
//				{
//					public void run() {
//						for (RecyclerView.ViewHolder holder : mAdditions) {
//							animateAddImpl(holder);
//						}
//						mAdditions.clear();
//					}
//				};
                if (removalsPending || movesPending)
                {
                    View view = mAdditions.get(0).itemView;
                    ViewCompat.postOnAnimationDelayed(view, adder,
                                                      (removalsPending ? getRemoveDuration() : 0) +
                                                      (movesPending ? getMoveDuration() : 0));
                }
                else
                {
                    adder.run();
                }
            }
        }
コード例 #2
0
        public override void runPendingAnimations()
        {
            bool removalsPending  = mPendingRemovals.Count > 0;
            bool movesPending     = mPendingMoves.Count > 0;
            bool changesPending   = mPendingChanges.Count > 0;
            bool additionsPending = mPendingAdditions.Count > 0;

            if (!removalsPending && !movesPending && !additionsPending && !changesPending)
            {
                // nothing to animate
                return;
            }
            // First, remove stuff
            foreach (RecyclerView.ViewHolder holder in mPendingRemovals)
            {
                animateRemoveImpl(holder);
            }
            mPendingRemovals.Clear();
            // Next, move stuff
            if (movesPending)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.ArrayList<MoveInfo> moves = new java.util.ArrayList<MoveInfo>();
                List <MoveInfo> moves = new List <MoveInfo>();
                moves.AddRange(mPendingMoves);
                mMovesList.Add(moves);
                mPendingMoves.Clear();
                Runnable mover = () =>
                {
                    foreach (MoveInfo moveInfo in moves)
                    {
                        animateMoveImpl(moveInfo.holder, moveInfo.fromX, moveInfo.fromY, moveInfo.toX, moveInfo.toY);
                    }
                    moves.Clear();
                    mMovesList.Remove(moves);
                };
                if (removalsPending)
                {
                    View view = moves[0].holder.itemView;
                    ViewCompat.postOnAnimationDelayed(view, mover, RemoveDuration);
                }
                else
                {
                    mover.run();
                }
            }
            // Next, change stuff, to run in parallel with move animations
            if (changesPending)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.ArrayList<ChangeInfo> changes = new java.util.ArrayList<ChangeInfo>();
                List <ChangeInfo> changes = new List <ChangeInfo>();
                changes.AddRange(mPendingChanges);
                mChangesList.Add(changes);
                mPendingChanges.Clear();
                Runnable changer = () =>
                {
                    foreach (ChangeInfo change in changes)
                    {
                        animateChangeImpl(change);
                    }
                    changes.Clear();
                    mChangesList.Remove(changes);
                };
                if (removalsPending)
                {
                    RecyclerView.ViewHolder holder = changes[0].oldHolder;
                    ViewCompat.postOnAnimationDelayed(holder.itemView, changer, RemoveDuration);
                }
                else
                {
                    changer.run();
                }
            }
            // Next, add stuff
            if (additionsPending)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.ArrayList<android.support.v7.widget.RecyclerView.ViewHolder> additions = new java.util.ArrayList<android.support.v7.widget.RecyclerView.ViewHolder>();
                List <RecyclerView.ViewHolder> additions = new List <RecyclerView.ViewHolder>();
                additions.AddRange(mPendingAdditions);
                mAdditionsList.Add(additions);
                mPendingAdditions.Clear();
                Runnable adder = () =>
                {
                    foreach (RecyclerView.ViewHolder holder in additions)
                    {
                        animateAddImpl(holder);
                    }
                    additions.Clear();
                    mAdditionsList.Remove(additions);
                };
                if (removalsPending || movesPending || changesPending)
                {
                    long removeDuration = removalsPending ? RemoveDuration : 0;
                    long moveDuration   = movesPending ? MoveDuration : 0;
                    long changeDuration = changesPending ? ChangeDuration : 0;
                    long totalDelay     = removeDuration + Math.Max(moveDuration, changeDuration);
                    View view           = additions[0].itemView;
                    ViewCompat.postOnAnimationDelayed(view, adder, totalDelay);
                }
                else
                {
                    adder.run();
                }
            }
        }