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

Commit f6f1495f authored by Josh Tsuji's avatar Josh Tsuji Committed by Automerger Merge Worker
Browse files

Merge "Add leadBubbleEndAction to expansion animation." into rvc-dev am: f51a85f6

Change-Id: Id2927d3977abb7260bd9a57e56d7085cc8a662bc
parents e0fcd366 f51a85f6
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -128,17 +128,31 @@ public class ExpandedAnimationController
     */
    private boolean mBubbleDraggedOutEnough = false;

    /** End action to run when the lead bubble's expansion animation completes. */
    @Nullable private Runnable mLeadBubbleEndAction;

    /**
     * Animates expanding the bubbles into a row along the top of the screen.
     * Animates expanding the bubbles into a row along the top of the screen, optionally running an
     * end action when the entire animation completes, and an end action when the lead bubble's
     * animation ends.
     */
    public void expandFromStack(@Nullable Runnable after) {
    public void expandFromStack(
            @Nullable Runnable after, @Nullable Runnable leadBubbleEndAction) {
        mAnimatingCollapse = false;
        mAnimatingExpand = true;
        mAfterExpand = after;
        mLeadBubbleEndAction = leadBubbleEndAction;

        startOrUpdatePathAnimation(true /* expanding */);
    }

    /**
     * Animates expanding the bubbles into a row along the top of the screen.
     */
    public void expandFromStack(@Nullable Runnable after) {
        expandFromStack(after, null /* leadBubbleEndAction */);
    }

    /** Animate collapsing the bubbles back to their stacked position. */
    public void collapseBackToStack(PointF collapsePoint, Runnable after) {
        mAnimatingExpand = false;
@@ -237,11 +251,17 @@ public class ExpandedAnimationController
                    ? (index * 10)
                    : ((mLayout.getChildCount() - index) * 10);

            final boolean isLeadBubble =
                    (firstBubbleLeads && index == 0)
                            || (!firstBubbleLeads && index == mLayout.getChildCount() - 1);

            animation
                    .followAnimatedTargetAlongPath(
                            path,
                            EXPAND_COLLAPSE_TARGET_ANIM_DURATION /* targetAnimDuration */,
                            Interpolators.LINEAR /* targetAnimInterpolator */)
                            Interpolators.LINEAR /* targetAnimInterpolator */,
                            isLeadBubble ? mLeadBubbleEndAction : null /* endAction */,
                            () -> mLeadBubbleEndAction = null /* endAction */)
                    .withStartDelay(startDelay)
                    .withStiffness(EXPAND_COLLAPSE_ANIM_STIFFNESS);
        }).startAll(after);
+18 −5
Original line number Diff line number Diff line
@@ -758,21 +758,34 @@ public class PhysicsAnimationLayout extends FrameLayout {
         * or {@link #position}, ultimately animating the view's position to the final point on the
         * given path.
         *
         * Any provided end listeners will be called when the physics-based animations kicked off by
         * the moving target have completed - not when the target animation completes.
         * @param pathAnimEndActions End actions to run after the animator that moves the target
         *                           along the path ends. The views following the target may still
         *                           be moving.
         */
        public PhysicsPropertyAnimator followAnimatedTargetAlongPath(
                Path path,
                int targetAnimDuration,
                TimeInterpolator targetAnimInterpolator,
                Runnable... endActions) {
                Runnable... pathAnimEndActions) {
            mPathAnimator = ObjectAnimator.ofFloat(
                    this, mCurrentPointOnPathXProperty, mCurrentPointOnPathYProperty, path);

            if (pathAnimEndActions != null) {
                mPathAnimator.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        for (Runnable action : pathAnimEndActions) {
                            if (action != null) {
                                action.run();
                            }
                        }
                    }
                });
            }

            mPathAnimator.setDuration(targetAnimDuration);
            mPathAnimator.setInterpolator(targetAnimInterpolator);

            mPositionEndActions = endActions;

            // Remove translation related values since we're going to ignore them and follow the
            // path instead.
            clearTranslationValues();