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

Commit de59969d authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make ProgressAnimator non-static." into main

parents 8bc520e8 11ab9bc5
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
    static final int RESULT_CODE_UNREGISTER = 1;
    @NonNull
    private final ResultReceiver mResultReceiver;
    @NonNull
    private final BackProgressAnimator mProgressAnimator = new BackProgressAnimator();

    public ImeOnBackInvokedDispatcher(Handler handler) {
        mResultReceiver = new ResultReceiver(handler) {
@@ -88,7 +90,7 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
        // cause a memory leak because the app side already clears the reference correctly.
        final IOnBackInvokedCallback iCallback =
                new WindowOnBackInvokedDispatcher.OnBackInvokedCallbackWrapper(
                        callback, false /* useWeakRef */);
                        callback, mProgressAnimator, false /* useWeakRef */);
        bundle.putBinder(RESULT_KEY_CALLBACK, iCallback.asBinder());
        bundle.putInt(RESULT_KEY_PRIORITY, priority);
        bundle.putInt(RESULT_KEY_ID, callback.hashCode());
@@ -179,6 +181,9 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
            }
        }
        mImeCallbacks.clear();
        // We should also stop running animations since all callbacks have been removed.
        // note: mSpring.skipToEnd(), in ProgressAnimator.reset(), requires the main handler.
        Handler.getMain().post(mProgressAnimator::reset);
    }

    static class ImeOnBackInvokedCallback implements OnBackInvokedCallback {
+11 −2
Original line number Diff line number Diff line
@@ -246,7 +246,10 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
                                    .ImeOnBackInvokedCallback
                                ? ((ImeOnBackInvokedDispatcher.ImeOnBackInvokedCallback)
                                        callback).getIOnBackInvokedCallback()
                                : new OnBackInvokedCallbackWrapper(callback, this);
                                : new OnBackInvokedCallbackWrapper(
                                        callback,
                                        mProgressAnimator,
                                        this);
                callbackInfo = new OnBackInvokedCallbackInfo(
                        iCallback,
                        priority,
@@ -272,7 +275,7 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
    }

    @NonNull
    private static final BackProgressAnimator mProgressAnimator = new BackProgressAnimator();
    private final BackProgressAnimator mProgressAnimator = new BackProgressAnimator();
    private boolean mIsDispatching = false;

    /**
@@ -339,18 +342,24 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
         * forwarded and registered on the app's {@link WindowOnBackInvokedDispatcher}. */
        @Nullable
        private final WindowOnBackInvokedDispatcher mDispatcher;
        @NonNull
        private final BackProgressAnimator mProgressAnimator;

        OnBackInvokedCallbackWrapper(
                @NonNull OnBackInvokedCallback callback,
                @NonNull BackProgressAnimator progressAnimator,
                WindowOnBackInvokedDispatcher dispatcher) {
            mCallbackRef = new CallbackRef(callback, true /* useWeakRef */);
            mProgressAnimator = progressAnimator;
            mDispatcher = dispatcher;
        }

        OnBackInvokedCallbackWrapper(
                @NonNull OnBackInvokedCallback callback,
                @NonNull BackProgressAnimator progressAnimator,
                boolean useWeakRef) {
            mCallbackRef = new CallbackRef(callback, useWeakRef);
            mProgressAnimator = progressAnimator;
            mDispatcher = null;
        }