Rabbit-R1/switch port/java/sources/androidx/activity/OnBackPressedDispatcher.java

506 lines
30 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package androidx.activity;
import android.os.Build;
import android.window.BackEvent;
import android.window.OnBackAnimationCallback;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
import androidx.activity.OnBackPressedDispatcher;
import androidx.core.app.NotificationCompat;
import androidx.core.util.Consumer;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleEventObserver;
import androidx.lifecycle.LifecycleOwner;
import io.sentry.protocol.SentryThread;
import io.sentry.protocol.TransactionInfo;
import java.util.Collection;
import java.util.Iterator;
import java.util.ListIterator;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.ArrayDeque;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
/* compiled from: OnBackPressedDispatcher.kt */
@Metadata(d1 = {"\u0000T\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u000f\u0018\u00002\u00020\u0001:\u0004)*+,B\u0013\b\u0017\u0012\n\b\u0002\u0010\u0002\u001a\u0004\u0018\u00010\u0003¢\u0006\u0002\u0010\u0004B\u001f\u0012\b\u0010\u0002\u001a\u0004\u0018\u00010\u0003\u0012\u000e\u0010\u0005\u001a\n\u0012\u0004\u0012\u00020\u0007\u0018\u00010\u0006¢\u0006\u0002\u0010\bJ\u0010\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\fH\u0007J\u0018\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u00172\u0006\u0010\u0015\u001a\u00020\fH\u0007J\u0015\u0010\u0018\u001a\u00020\u00192\u0006\u0010\u0015\u001a\u00020\fH\u0001¢\u0006\u0002\b\u001aJ\b\u0010\u001b\u001a\u00020\u0014H\u0007J\u0010\u0010\u001c\u001a\u00020\u00142\u0006\u0010\u001d\u001a\u00020\u001eH\u0007J\u0010\u0010\u001f\u001a\u00020\u00142\u0006\u0010\u001d\u001a\u00020\u001eH\u0007J\b\u0010\n\u001a\u00020\u0007H\u0007J\b\u0010 \u001a\u00020\u0014H\u0003J\b\u0010!\u001a\u00020\u0014H\u0007J\u0010\u0010\"\u001a\u00020\u00142\u0006\u0010\u001d\u001a\u00020\u001eH\u0003J\u0010\u0010#\u001a\u00020\u00142\u0006\u0010\u001d\u001a\u00020\u001eH\u0003J\u0010\u0010$\u001a\u00020\u00142\u0006\u0010%\u001a\u00020\u000eH\u0007J\u0010\u0010&\u001a\u00020\u00142\u0006\u0010'\u001a\u00020\u0007H\u0003J\b\u0010(\u001a\u00020\u0014H\u0002R\u000e\u0010\t\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0002\u001a\u0004\u0018\u00010\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u000b\u001a\u0004\u0018\u00010\fX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\r\u001a\u0004\u0018\u00010\u000eX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u000f\u001a\u0004\u0018\u00010\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u0011\u001a\b\u0012\u0004\u0012\u00020\f0\u0012X\u0082\u0004¢\u0006\u0002\n\u0000R\u0016\u0010\u0005\u001a\n\u0012\u0004\u0012\u00020\u0007\u0018\u00010\u0006X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006-"}, d2 = {"Landroidx/activity/OnBackPressedDispatcher;", "", "fallbackOnBackPressed", "Ljava/lang/Runnable;", "(Ljava/lang/Runnable;)V", "onHasEnabledCallbacksChanged", "Landroidx/core/util/Consumer;", "", "(Ljava/lang/Runnable;Landroidx/core/util/Consumer;)V", "backInvokedCallbackRegistered", "hasEnabledCallbacks", "inProgressCallback", "Landroidx/activity/OnBackPressedCallback;", "invokedDispatcher", "Landroid/window/OnBackInvokedDispatcher;", "onBackInvokedCallback", "Landroid/window/OnBackInvokedCallback;", "onBackPressedCallbacks", "Lkotlin/collections/ArrayDeque;", "addCallback", "", "onBackPressedCallback", "owner", "Landroidx/lifecycle/LifecycleOwner;", "addCancellableCallback", "Landroidx/activity/Cancellable;", "addCancellableCallback$activity_release", "dispatchOnBackCancelled", "dispatchOnBackProgressed", "backEvent", "Landroidx/activity/BackEventCompat;", "dispatchOnBackStarted", "onBackCancelled", "onBackPressed", "onBackProgressed", "onBackStarted", "setOnBackInvokedDispatcher", "invoker", "updateBackInvokedCallbackState", "shouldBeRegistered", "updateEnabledCallbacks", "Api33Impl", "Api34Impl", "LifecycleOnBackPressedCancellable", "OnBackPressedCancellable", "activity_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public final class OnBackPressedDispatcher {
private boolean backInvokedCallbackRegistered;
private final Runnable fallbackOnBackPressed;
private boolean hasEnabledCallbacks;
private OnBackPressedCallback inProgressCallback;
private OnBackInvokedDispatcher invokedDispatcher;
private OnBackInvokedCallback onBackInvokedCallback;
private final ArrayDeque<OnBackPressedCallback> onBackPressedCallbacks;
private final Consumer<Boolean> onHasEnabledCallbacksChanged;
/* JADX WARN: Multi-variable type inference failed */
public OnBackPressedDispatcher() {
this(null, 1, 0 == true ? 1 : 0);
}
/* renamed from: hasEnabledCallbacks, reason: from getter */
public final boolean getHasEnabledCallbacks() {
return this.hasEnabledCallbacks;
}
public OnBackPressedDispatcher(Runnable runnable, Consumer<Boolean> consumer) {
OnBackInvokedCallback createOnBackInvokedCallback;
this.fallbackOnBackPressed = runnable;
this.onHasEnabledCallbacksChanged = consumer;
this.onBackPressedCallbacks = new ArrayDeque<>();
if (Build.VERSION.SDK_INT >= 33) {
if (Build.VERSION.SDK_INT >= 34) {
createOnBackInvokedCallback = Api34Impl.INSTANCE.createOnBackAnimationCallback(new Function1<BackEventCompat, Unit>() { // from class: androidx.activity.OnBackPressedDispatcher.1
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Unit invoke(BackEventCompat backEventCompat) {
invoke2(backEventCompat);
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: avoid collision after fix types in other method */
public final void invoke2(BackEventCompat backEvent) {
Intrinsics.checkNotNullParameter(backEvent, "backEvent");
OnBackPressedDispatcher.this.onBackStarted(backEvent);
}
}, new Function1<BackEventCompat, Unit>() { // from class: androidx.activity.OnBackPressedDispatcher.2
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Unit invoke(BackEventCompat backEventCompat) {
invoke2(backEventCompat);
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: avoid collision after fix types in other method */
public final void invoke2(BackEventCompat backEvent) {
Intrinsics.checkNotNullParameter(backEvent, "backEvent");
OnBackPressedDispatcher.this.onBackProgressed(backEvent);
}
}, new Function0<Unit>() { // from class: androidx.activity.OnBackPressedDispatcher.3
{
super(0);
}
@Override // kotlin.jvm.functions.Function0
public /* bridge */ /* synthetic */ Unit invoke() {
invoke2();
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: avoid collision after fix types in other method */
public final void invoke2() {
OnBackPressedDispatcher.this.onBackPressed();
}
}, new Function0<Unit>() { // from class: androidx.activity.OnBackPressedDispatcher.4
{
super(0);
}
@Override // kotlin.jvm.functions.Function0
public /* bridge */ /* synthetic */ Unit invoke() {
invoke2();
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: avoid collision after fix types in other method */
public final void invoke2() {
OnBackPressedDispatcher.this.onBackCancelled();
}
});
} else {
createOnBackInvokedCallback = Api33Impl.INSTANCE.createOnBackInvokedCallback(new Function0<Unit>() { // from class: androidx.activity.OnBackPressedDispatcher.5
{
super(0);
}
@Override // kotlin.jvm.functions.Function0
public /* bridge */ /* synthetic */ Unit invoke() {
invoke2();
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: avoid collision after fix types in other method */
public final void invoke2() {
OnBackPressedDispatcher.this.onBackPressed();
}
});
}
this.onBackInvokedCallback = createOnBackInvokedCallback;
}
}
public /* synthetic */ OnBackPressedDispatcher(Runnable runnable, int i, DefaultConstructorMarker defaultConstructorMarker) {
this((i & 1) != 0 ? null : runnable);
}
public OnBackPressedDispatcher(Runnable runnable) {
this(runnable, null);
}
public final void setOnBackInvokedDispatcher(OnBackInvokedDispatcher invoker) {
Intrinsics.checkNotNullParameter(invoker, "invoker");
this.invokedDispatcher = invoker;
updateBackInvokedCallbackState(this.hasEnabledCallbacks);
}
private final void updateBackInvokedCallbackState(boolean shouldBeRegistered) {
OnBackInvokedDispatcher onBackInvokedDispatcher = this.invokedDispatcher;
OnBackInvokedCallback onBackInvokedCallback = this.onBackInvokedCallback;
if (onBackInvokedDispatcher == null || onBackInvokedCallback == null) {
return;
}
if (shouldBeRegistered && !this.backInvokedCallbackRegistered) {
Api33Impl.INSTANCE.registerOnBackInvokedCallback(onBackInvokedDispatcher, 0, onBackInvokedCallback);
this.backInvokedCallbackRegistered = true;
} else {
if (shouldBeRegistered || !this.backInvokedCallbackRegistered) {
return;
}
Api33Impl.INSTANCE.unregisterOnBackInvokedCallback(onBackInvokedDispatcher, onBackInvokedCallback);
this.backInvokedCallbackRegistered = false;
}
}
/* JADX INFO: Access modifiers changed from: private */
public final void updateEnabledCallbacks() {
boolean z = this.hasEnabledCallbacks;
ArrayDeque<OnBackPressedCallback> arrayDeque = this.onBackPressedCallbacks;
boolean z2 = false;
if (!(arrayDeque instanceof Collection) || !arrayDeque.isEmpty()) {
Iterator<OnBackPressedCallback> it = arrayDeque.iterator();
while (true) {
if (!it.hasNext()) {
break;
} else if (it.next().getIsEnabled()) {
z2 = true;
break;
}
}
}
this.hasEnabledCallbacks = z2;
if (z2 != z) {
Consumer<Boolean> consumer = this.onHasEnabledCallbacksChanged;
if (consumer != null) {
consumer.accept(Boolean.valueOf(z2));
}
if (Build.VERSION.SDK_INT >= 33) {
updateBackInvokedCallbackState(z2);
}
}
}
public final void addCallback(OnBackPressedCallback onBackPressedCallback) {
Intrinsics.checkNotNullParameter(onBackPressedCallback, "onBackPressedCallback");
addCancellableCallback$activity_release(onBackPressedCallback);
}
public final Cancellable addCancellableCallback$activity_release(OnBackPressedCallback onBackPressedCallback) {
Intrinsics.checkNotNullParameter(onBackPressedCallback, "onBackPressedCallback");
this.onBackPressedCallbacks.add(onBackPressedCallback);
OnBackPressedCancellable onBackPressedCancellable = new OnBackPressedCancellable(this, onBackPressedCallback);
onBackPressedCallback.addCancellable(onBackPressedCancellable);
updateEnabledCallbacks();
onBackPressedCallback.setEnabledChangedCallback$activity_release(new OnBackPressedDispatcher$addCancellableCallback$1(this));
return onBackPressedCancellable;
}
public final void addCallback(LifecycleOwner owner, OnBackPressedCallback onBackPressedCallback) {
Intrinsics.checkNotNullParameter(owner, "owner");
Intrinsics.checkNotNullParameter(onBackPressedCallback, "onBackPressedCallback");
Lifecycle lifecycle = owner.getLifecycle();
if (lifecycle.getState() == Lifecycle.State.DESTROYED) {
return;
}
onBackPressedCallback.addCancellable(new LifecycleOnBackPressedCancellable(this, lifecycle, onBackPressedCallback));
updateEnabledCallbacks();
onBackPressedCallback.setEnabledChangedCallback$activity_release(new OnBackPressedDispatcher$addCallback$1(this));
}
public final void dispatchOnBackStarted(BackEventCompat backEvent) {
Intrinsics.checkNotNullParameter(backEvent, "backEvent");
onBackStarted(backEvent);
}
/* JADX INFO: Access modifiers changed from: private */
public final void onBackStarted(BackEventCompat backEvent) {
OnBackPressedCallback onBackPressedCallback;
ArrayDeque<OnBackPressedCallback> arrayDeque = this.onBackPressedCallbacks;
ListIterator<OnBackPressedCallback> listIterator = arrayDeque.listIterator(arrayDeque.size());
while (true) {
if (!listIterator.hasPrevious()) {
onBackPressedCallback = null;
break;
} else {
onBackPressedCallback = listIterator.previous();
if (onBackPressedCallback.getIsEnabled()) {
break;
}
}
}
OnBackPressedCallback onBackPressedCallback2 = onBackPressedCallback;
this.inProgressCallback = onBackPressedCallback2;
if (onBackPressedCallback2 != null) {
onBackPressedCallback2.handleOnBackStarted(backEvent);
}
}
public final void dispatchOnBackProgressed(BackEventCompat backEvent) {
Intrinsics.checkNotNullParameter(backEvent, "backEvent");
onBackProgressed(backEvent);
}
/* JADX INFO: Access modifiers changed from: private */
public final void onBackProgressed(BackEventCompat backEvent) {
OnBackPressedCallback onBackPressedCallback;
OnBackPressedCallback onBackPressedCallback2 = this.inProgressCallback;
if (onBackPressedCallback2 == null) {
ArrayDeque<OnBackPressedCallback> arrayDeque = this.onBackPressedCallbacks;
ListIterator<OnBackPressedCallback> listIterator = arrayDeque.listIterator(arrayDeque.size());
while (true) {
if (!listIterator.hasPrevious()) {
onBackPressedCallback = null;
break;
} else {
onBackPressedCallback = listIterator.previous();
if (onBackPressedCallback.getIsEnabled()) {
break;
}
}
}
onBackPressedCallback2 = onBackPressedCallback;
}
if (onBackPressedCallback2 != null) {
onBackPressedCallback2.handleOnBackProgressed(backEvent);
}
}
public final void onBackPressed() {
OnBackPressedCallback onBackPressedCallback;
OnBackPressedCallback onBackPressedCallback2 = this.inProgressCallback;
if (onBackPressedCallback2 == null) {
ArrayDeque<OnBackPressedCallback> arrayDeque = this.onBackPressedCallbacks;
ListIterator<OnBackPressedCallback> listIterator = arrayDeque.listIterator(arrayDeque.size());
while (true) {
if (!listIterator.hasPrevious()) {
onBackPressedCallback = null;
break;
} else {
onBackPressedCallback = listIterator.previous();
if (onBackPressedCallback.getIsEnabled()) {
break;
}
}
}
onBackPressedCallback2 = onBackPressedCallback;
}
this.inProgressCallback = null;
if (onBackPressedCallback2 != null) {
onBackPressedCallback2.handleOnBackPressed();
return;
}
Runnable runnable = this.fallbackOnBackPressed;
if (runnable != null) {
runnable.run();
}
}
public final void dispatchOnBackCancelled() {
onBackCancelled();
}
/* JADX INFO: Access modifiers changed from: private */
public final void onBackCancelled() {
OnBackPressedCallback onBackPressedCallback;
OnBackPressedCallback onBackPressedCallback2 = this.inProgressCallback;
if (onBackPressedCallback2 == null) {
ArrayDeque<OnBackPressedCallback> arrayDeque = this.onBackPressedCallbacks;
ListIterator<OnBackPressedCallback> listIterator = arrayDeque.listIterator(arrayDeque.size());
while (true) {
if (!listIterator.hasPrevious()) {
onBackPressedCallback = null;
break;
} else {
onBackPressedCallback = listIterator.previous();
if (onBackPressedCallback.getIsEnabled()) {
break;
}
}
}
onBackPressedCallback2 = onBackPressedCallback;
}
this.inProgressCallback = null;
if (onBackPressedCallback2 != null) {
onBackPressedCallback2.handleOnBackCancelled();
}
}
/* JADX INFO: Access modifiers changed from: private */
/* compiled from: OnBackPressedDispatcher.kt */
@Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\b\u0082\u0004\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\b\u0010\u0005\u001a\u00020\u0006H\u0016R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0007"}, d2 = {"Landroidx/activity/OnBackPressedDispatcher$OnBackPressedCancellable;", "Landroidx/activity/Cancellable;", "onBackPressedCallback", "Landroidx/activity/OnBackPressedCallback;", "(Landroidx/activity/OnBackPressedDispatcher;Landroidx/activity/OnBackPressedCallback;)V", "cancel", "", "activity_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public final class OnBackPressedCancellable implements Cancellable {
private final OnBackPressedCallback onBackPressedCallback;
final /* synthetic */ OnBackPressedDispatcher this$0;
public OnBackPressedCancellable(OnBackPressedDispatcher onBackPressedDispatcher, OnBackPressedCallback onBackPressedCallback) {
Intrinsics.checkNotNullParameter(onBackPressedCallback, "onBackPressedCallback");
this.this$0 = onBackPressedDispatcher;
this.onBackPressedCallback = onBackPressedCallback;
}
@Override // androidx.activity.Cancellable
public void cancel() {
this.this$0.onBackPressedCallbacks.remove(this.onBackPressedCallback);
if (Intrinsics.areEqual(this.this$0.inProgressCallback, this.onBackPressedCallback)) {
this.onBackPressedCallback.handleOnBackCancelled();
this.this$0.inProgressCallback = null;
}
this.onBackPressedCallback.removeCancellable(this);
Function0<Unit> enabledChangedCallback$activity_release = this.onBackPressedCallback.getEnabledChangedCallback$activity_release();
if (enabledChangedCallback$activity_release != null) {
enabledChangedCallback$activity_release.invoke();
}
this.onBackPressedCallback.setEnabledChangedCallback$activity_release(null);
}
}
/* JADX INFO: Access modifiers changed from: private */
/* compiled from: OnBackPressedDispatcher.kt */
@Metadata(d1 = {"\u00000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\b\u0082\u0004\u0018\u00002\u00020\u00012\u00020\u0002B\u0015\u0012\u0006\u0010\u0003\u001a\u00020\u0004\u0012\u0006\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u0007J\b\u0010\t\u001a\u00020\nH\u0016J\u0018\u0010\u000b\u001a\u00020\n2\u0006\u0010\f\u001a\u00020\r2\u0006\u0010\u000e\u001a\u00020\u000fH\u0016R\u0010\u0010\b\u001a\u0004\u0018\u00010\u0002X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0010"}, d2 = {"Landroidx/activity/OnBackPressedDispatcher$LifecycleOnBackPressedCancellable;", "Landroidx/lifecycle/LifecycleEventObserver;", "Landroidx/activity/Cancellable;", "lifecycle", "Landroidx/lifecycle/Lifecycle;", "onBackPressedCallback", "Landroidx/activity/OnBackPressedCallback;", "(Landroidx/activity/OnBackPressedDispatcher;Landroidx/lifecycle/Lifecycle;Landroidx/activity/OnBackPressedCallback;)V", "currentCancellable", "cancel", "", "onStateChanged", TransactionInfo.JsonKeys.SOURCE, "Landroidx/lifecycle/LifecycleOwner;", NotificationCompat.CATEGORY_EVENT, "Landroidx/lifecycle/Lifecycle$Event;", "activity_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public final class LifecycleOnBackPressedCancellable implements LifecycleEventObserver, Cancellable {
private Cancellable currentCancellable;
private final Lifecycle lifecycle;
private final OnBackPressedCallback onBackPressedCallback;
final /* synthetic */ OnBackPressedDispatcher this$0;
public LifecycleOnBackPressedCancellable(OnBackPressedDispatcher onBackPressedDispatcher, Lifecycle lifecycle, OnBackPressedCallback onBackPressedCallback) {
Intrinsics.checkNotNullParameter(lifecycle, "lifecycle");
Intrinsics.checkNotNullParameter(onBackPressedCallback, "onBackPressedCallback");
this.this$0 = onBackPressedDispatcher;
this.lifecycle = lifecycle;
this.onBackPressedCallback = onBackPressedCallback;
lifecycle.addObserver(this);
}
@Override // androidx.lifecycle.LifecycleEventObserver
public void onStateChanged(LifecycleOwner source, Lifecycle.Event event) {
Intrinsics.checkNotNullParameter(source, "source");
Intrinsics.checkNotNullParameter(event, "event");
if (event == Lifecycle.Event.ON_START) {
this.currentCancellable = this.this$0.addCancellableCallback$activity_release(this.onBackPressedCallback);
return;
}
if (event != Lifecycle.Event.ON_STOP) {
if (event == Lifecycle.Event.ON_DESTROY) {
cancel();
}
} else {
Cancellable cancellable = this.currentCancellable;
if (cancellable != null) {
cancellable.cancel();
}
}
}
@Override // androidx.activity.Cancellable
public void cancel() {
this.lifecycle.removeObserver(this);
this.onBackPressedCallback.removeCancellable(this);
Cancellable cancellable = this.currentCancellable;
if (cancellable != null) {
cancellable.cancel();
}
this.currentCancellable = null;
}
}
/* compiled from: OnBackPressedDispatcher.kt */
@Metadata(d1 = {"\u0000&\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0003\\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0016\u0010\u0003\u001a\u00020\u00042\f\u0010\u0005\u001a\b\u0012\u0004\u0012\u00020\u00070\u0006H\u0007J \u0010\b\u001a\u00020\u00072\u0006\u0010\t\u001a\u00020\u00012\u0006\u0010\n\u001a\u00020\u000b2\u0006\u0010\f\u001a\u00020\u0001H\u0007J\u0018\u0010\r\u001a\u00020\u00072\u0006\u0010\t\u001a\u00020\u00012\u0006\u0010\f\u001a\u00020\u0001H\u0007¨\u0006\u000e"}, d2 = {"Landroidx/activity/OnBackPressedDispatcher$Api33Impl;", "", "()V", "createOnBackInvokedCallback", "Landroid/window/OnBackInvokedCallback;", "onBackInvoked", "Lkotlin/Function0;", "", "registerOnBackInvokedCallback", "dispatcher", SentryThread.JsonKeys.PRIORITY, "", "callback", "unregisterOnBackInvokedCallback", "activity_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public static final class Api33Impl {
public static final Api33Impl INSTANCE = new Api33Impl();
private Api33Impl() {
}
public final void registerOnBackInvokedCallback(Object dispatcher, int priority, Object callback) {
Intrinsics.checkNotNullParameter(dispatcher, "dispatcher");
Intrinsics.checkNotNullParameter(callback, "callback");
((OnBackInvokedDispatcher) dispatcher).registerOnBackInvokedCallback(priority, (OnBackInvokedCallback) callback);
}
public final void unregisterOnBackInvokedCallback(Object dispatcher, Object callback) {
Intrinsics.checkNotNullParameter(dispatcher, "dispatcher");
Intrinsics.checkNotNullParameter(callback, "callback");
((OnBackInvokedDispatcher) dispatcher).unregisterOnBackInvokedCallback((OnBackInvokedCallback) callback);
}
/* JADX INFO: Access modifiers changed from: private */
public static final void createOnBackInvokedCallback$lambda$0(Function0 onBackInvoked) {
Intrinsics.checkNotNullParameter(onBackInvoked, "$onBackInvoked");
onBackInvoked.invoke();
}
public final OnBackInvokedCallback createOnBackInvokedCallback(final Function0<Unit> onBackInvoked) {
Intrinsics.checkNotNullParameter(onBackInvoked, "onBackInvoked");
return new OnBackInvokedCallback() { // from class: androidx.activity.OnBackPressedDispatcher$Api33Impl$$ExternalSyntheticLambda0
@Override // android.window.OnBackInvokedCallback
public final void onBackInvoked() {
OnBackPressedDispatcher.Api33Impl.createOnBackInvokedCallback$lambda$0(Function0.this);
}
};
}
}
/* compiled from: OnBackPressedDispatcher.kt */
@Metadata(d1 = {"\u00002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002Jj\u0010\u0003\u001a\u00020\u00042!\u0010\u0005\u001a\u001d\u0012\u0013\u0012\u00110\u0007¢\u0006\f\b\b\u0012\b\b\t\u0012\u0004\b\b(\n\u0012\u0004\u0012\u00020\u000b0\u00062!\u0010\f\u001a\u001d\u0012\u0013\u0012\u00110\u0007¢\u0006\f\b\b\u0012\b\b\t\u0012\u0004\b\b(\n\u0012\u0004\u0012\u00020\u000b0\u00062\f\u0010\r\u001a\b\u0012\u0004\u0012\u00020\u000b0\u000e2\f\u0010\u000f\u001a\b\u0012\u0004\u0012\u00020\u000b0\u000eH\u0007¨\u0006\u0010"}, d2 = {"Landroidx/activity/OnBackPressedDispatcher$Api34Impl;", "", "()V", "createOnBackAnimationCallback", "Landroid/window/OnBackInvokedCallback;", "onBackStarted", "Lkotlin/Function1;", "Landroidx/activity/BackEventCompat;", "Lkotlin/ParameterName;", "name", "backEvent", "", "onBackProgressed", "onBackInvoked", "Lkotlin/Function0;", "onBackCancelled", "activity_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public static final class Api34Impl {
public static final Api34Impl INSTANCE = new Api34Impl();
private Api34Impl() {
}
public final OnBackInvokedCallback createOnBackAnimationCallback(final Function1<? super BackEventCompat, Unit> onBackStarted, final Function1<? super BackEventCompat, Unit> onBackProgressed, final Function0<Unit> onBackInvoked, final Function0<Unit> onBackCancelled) {
Intrinsics.checkNotNullParameter(onBackStarted, "onBackStarted");
Intrinsics.checkNotNullParameter(onBackProgressed, "onBackProgressed");
Intrinsics.checkNotNullParameter(onBackInvoked, "onBackInvoked");
Intrinsics.checkNotNullParameter(onBackCancelled, "onBackCancelled");
return new OnBackAnimationCallback() { // from class: androidx.activity.OnBackPressedDispatcher$Api34Impl$createOnBackAnimationCallback$1
@Override // android.window.OnBackAnimationCallback
public void onBackStarted(BackEvent backEvent) {
Intrinsics.checkNotNullParameter(backEvent, "backEvent");
onBackStarted.invoke(new BackEventCompat(backEvent));
}
@Override // android.window.OnBackAnimationCallback
public void onBackProgressed(BackEvent backEvent) {
Intrinsics.checkNotNullParameter(backEvent, "backEvent");
onBackProgressed.invoke(new BackEventCompat(backEvent));
}
@Override // android.window.OnBackInvokedCallback
public void onBackInvoked() {
onBackInvoked.invoke();
}
@Override // android.window.OnBackAnimationCallback
public void onBackCancelled() {
onBackCancelled.invoke();
}
};
}
}
}