Loading core/java/android/window/ImeOnBackInvokedDispatcher.java +6 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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()); Loading Loading @@ -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 { Loading core/java/android/window/WindowOnBackInvokedDispatcher.java +11 −2 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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; /** Loading Loading @@ -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; } Loading Loading
core/java/android/window/ImeOnBackInvokedDispatcher.java +6 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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()); Loading Loading @@ -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 { Loading
core/java/android/window/WindowOnBackInvokedDispatcher.java +11 −2 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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; /** Loading Loading @@ -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; } Loading