Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0fcded7 authored by Kevin's avatar Kevin
Browse files

Move shared end pending anim logic for reusability

Some of the logic in endAnimations and endAnimation is shared and should
be moved to a common helper method.

Test: Builds and functions as before
Change-Id: I4973d50ad8778bb397938b5d65d9f95f48ff145b
parent f079b277
Loading
Loading
Loading
Loading
+17 −26
Original line number Diff line number Diff line
@@ -216,20 +216,8 @@ public final class ContentFillItemAnimator extends SimpleItemAnimator {
    @Override
    public void endAnimation(@NonNull ViewHolder item) {
        for (int i = mPendingAnims.size() - 1; i >= 0; i--) {
            PendingAnimation pendAnim = mPendingAnims.get(i);
            if (pendAnim.viewHolder == item) {
            endPendingAnimation(mPendingAnims.get(i));
            mPendingAnims.remove(i);
                switch (pendAnim.animType) {
                    case ANIM_TYPE_REMOVE:
                        dispatchRemoveFinished(item);
                        break;
                    case ANIM_TYPE_CHANGE:
                        dispatchChangeFinished(item, true /* oldItem */);
                        break;
                    default:
                        break;
                }
            }
        }
        dispatchFinishedWhenDone();
    }
@@ -237,7 +225,18 @@ public final class ContentFillItemAnimator extends SimpleItemAnimator {
    @Override
    public void endAnimations() {
        for (int i = mPendingAnims.size() - 1; i >= 0; i--) {
            PendingAnimation pendAnim = mPendingAnims.get(i);
            endPendingAnimation(mPendingAnims.get(i));
            mPendingAnims.remove(i);
        }
        for (int i = mRunningAnims.size() - 1; i >= 0; i--) {
            ObjectAnimator anim = mRunningAnims.get(i);
            // This calls the on end animation callback which will set values to their end target.
            anim.cancel();
        }
        dispatchAnimationsFinished();
    }

    private void endPendingAnimation(PendingAnimation pendAnim) {
        ViewHolder item = pendAnim.viewHolder;
        switch (pendAnim.animType) {
            case ANIM_TYPE_REMOVE:
@@ -249,14 +248,6 @@ public final class ContentFillItemAnimator extends SimpleItemAnimator {
            default:
                break;
        }
            mPendingAnims.remove(i);
        }
        for (int i = mRunningAnims.size() - 1; i >= 0; i--) {
            ObjectAnimator anim = mRunningAnims.get(i);
            // This calls the on end animation callback which will set values to their end target.
            anim.cancel();
        }
        dispatchAnimationsFinished();
    }

    @Override