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

Commit ab431c4c authored by Adrian Roos's avatar Adrian Roos Committed by Automerger Merge Worker
Browse files

Merge "InsetsController: Add missing onWindowInsetsAnimationEnd when...

Merge "InsetsController: Add missing onWindowInsetsAnimationEnd when cancelling" into rvc-dev am: c7577d48

Change-Id: Ia2fde50aeeb18b6fa595d22c8c491fedd9f31cfb
parents 98c797a2 c7577d48
Loading
Loading
Loading
Loading
+27 −8
Original line number Diff line number Diff line
@@ -70,6 +70,8 @@ import java.util.function.BiFunction;
 */
public class InsetsController implements WindowInsetsController, InsetsAnimationControlCallbacks {

    private int mTypesBeingCancelled;

    public interface Host {

        Handler getHandler();
@@ -809,6 +811,12 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            @AnimationType int animationType,
            @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation,
            boolean useInsetsAnimationThread) {
        if ((types & mTypesBeingCancelled) != 0) {
            throw new IllegalStateException("Cannot start a new insets animation of "
                    + Type.toString(types)
                    + " while an existing " + Type.toString(mTypesBeingCancelled)
                    + " is being cancelled.");
        }
        if (types == 0) {
            // nothing to animate.
            listener.onCancelled(null);
@@ -868,7 +876,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        if (DEBUG) Log.d(TAG, "Animation added to runner. useInsetsAnimationThread: "
                + useInsetsAnimationThread);
        if (cancellationSignal != null) {
            cancellationSignal.setOnCancelListener(runner::cancel);
            cancellationSignal.setOnCancelListener(() -> {
                cancelAnimation(runner, true /* invokeCallback */);
            });
        }
        if (layoutInsetsDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN) {
            showDirectly(types);
@@ -963,6 +973,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
    }

    private void cancelExistingControllers(@InsetsType int types) {
        final int originalmTypesBeingCancelled = mTypesBeingCancelled;
        mTypesBeingCancelled |= types;
        try {
            for (int i = mRunningAnimations.size() - 1; i >= 0; i--) {
                InsetsAnimationControlRunner control = mRunningAnimations.get(i).runner;
                if ((control.getTypes() & types) != 0) {
@@ -972,6 +985,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            if ((types & ime()) != 0) {
                abortPendingImeControlRequest();
            }
        } finally {
            mTypesBeingCancelled = originalmTypesBeingCancelled;
        }
    }

    private void abortPendingImeControlRequest() {
@@ -1029,6 +1045,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                        mHost.notifyInsetsChanged();
                    }
                }
                if (invokeCallback && runningAnimation.startDispatched) {
                    dispatchAnimationEnd(runningAnimation.runner.getAnimation());
                }
                break;
            }
        }