what-the-bank/sources/androidx/activity/OnBackPressedDispatcher.java

219 lines
6.5 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package androidx.activity;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
import androidx.activity.OnBackPressedDispatcher;
import java.util.ArrayDeque;
import java.util.Iterator;
import java.util.Objects;
import o.C17488xFm;
import o.InterfaceC16541pFg;
import o.InterfaceC3451axm;
import o.QUU;
import o.ZqN;
import o.jbe;
import o.wdQ;
/* loaded from: classes.dex */
public final class OnBackPressedDispatcher {
public OnBackInvokedDispatcher a;
private boolean b;
private final Runnable c;
final ArrayDeque<ZqN> d;
QUU<Boolean> e;
private OnBackInvokedCallback i;
public final void bz_(OnBackInvokedDispatcher onBackInvokedDispatcher) {
this.a = onBackInvokedDispatcher;
e();
}
public final void e() {
boolean c = c();
OnBackInvokedDispatcher onBackInvokedDispatcher = this.a;
if (onBackInvokedDispatcher != null) {
if (c && !this.b) {
IeS.e(onBackInvokedDispatcher, 0, this.i);
this.b = true;
} else {
if (c || !this.b) {
return;
}
IeS.a(onBackInvokedDispatcher, this.i);
this.b = false;
}
}
}
public OnBackPressedDispatcher() {
this(null);
}
public OnBackPressedDispatcher(Runnable runnable) {
this.d = new ArrayDeque<>();
this.b = false;
this.c = runnable;
if (C17488xFm.c()) {
this.e = new QUU(this) { // from class: o.ojQ
public final OnBackPressedDispatcher a;
@Override // o.QUU
public final void accept(Object obj) {
OnBackPressedDispatcher onBackPressedDispatcher = this.a;
if (C17488xFm.c()) {
onBackPressedDispatcher.e();
}
}
{
this.a = this;
}
};
this.i = IeS.bA_(new Runnable(this) { // from class: o.saX
public final OnBackPressedDispatcher b;
@Override // java.lang.Runnable
public final void run() {
this.b.a();
}
{
this.b = this;
}
});
}
}
public final void d(InterfaceC16541pFg interfaceC16541pFg, ZqN zqN) {
wdQ lifecycle = interfaceC16541pFg.getLifecycle();
if (lifecycle.a() == wdQ.IeS.DESTROYED) {
return;
}
zqN.addCancellable(new LifecycleOnBackPressedCancellable(this, lifecycle, zqN));
if (C17488xFm.c()) {
e();
zqN.setIsEnabledConsumer(this.e);
}
}
private boolean c() {
Iterator<ZqN> descendingIterator = this.d.descendingIterator();
while (descendingIterator.hasNext()) {
if (descendingIterator.next().isEnabled()) {
return true;
}
}
return false;
}
public final void a() {
Iterator<ZqN> descendingIterator = this.d.descendingIterator();
while (descendingIterator.hasNext()) {
ZqN next = descendingIterator.next();
if (next.isEnabled()) {
next.handleOnBackPressed();
return;
}
}
Runnable runnable = this.c;
if (runnable != null) {
runnable.run();
}
}
/* loaded from: classes.dex */
class RVV implements o.RVV {
final OnBackPressedDispatcher c;
private final ZqN d;
RVV(OnBackPressedDispatcher onBackPressedDispatcher, ZqN zqN) {
this.c = onBackPressedDispatcher;
this.d = zqN;
}
@Override // o.RVV
public final void b() {
this.c.d.remove(this.d);
this.d.removeCancellable(this);
if (C17488xFm.c()) {
this.d.setIsEnabledConsumer(null);
this.c.e();
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public class LifecycleOnBackPressedCancellable implements InterfaceC3451axm, o.RVV {
final OnBackPressedDispatcher a;
private final wdQ b;
private o.RVV c;
private final ZqN e;
LifecycleOnBackPressedCancellable(OnBackPressedDispatcher onBackPressedDispatcher, wdQ wdq, ZqN zqN) {
this.a = onBackPressedDispatcher;
this.b = wdq;
this.e = zqN;
wdq.e(this);
}
@Override // o.InterfaceC3451axm
public final void c(InterfaceC16541pFg interfaceC16541pFg, wdQ.HBt hBt) {
if (hBt != wdQ.HBt.ON_START) {
if (hBt != wdQ.HBt.ON_STOP) {
if (hBt == wdQ.HBt.ON_DESTROY) {
b();
return;
}
return;
} else {
o.RVV rvv = this.c;
if (rvv != null) {
rvv.b();
return;
}
return;
}
}
OnBackPressedDispatcher onBackPressedDispatcher = this.a;
ZqN zqN = this.e;
onBackPressedDispatcher.d.add(zqN);
RVV rvv2 = new RVV(onBackPressedDispatcher, zqN);
zqN.addCancellable(rvv2);
if (C17488xFm.c()) {
onBackPressedDispatcher.e();
zqN.setIsEnabledConsumer(onBackPressedDispatcher.e);
}
this.c = rvv2;
}
@Override // o.RVV
public final void b() {
this.b.a(this);
this.e.removeCancellable(this);
o.RVV rvv = this.c;
if (rvv != null) {
rvv.b();
this.c = null;
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class IeS {
static void e(Object obj, int i, Object obj2) {
((OnBackInvokedDispatcher) obj).registerOnBackInvokedCallback(i, (OnBackInvokedCallback) obj2);
}
static void a(Object obj, Object obj2) {
((OnBackInvokedDispatcher) obj).unregisterOnBackInvokedCallback((OnBackInvokedCallback) obj2);
}
static OnBackInvokedCallback bA_(Runnable runnable) {
Objects.requireNonNull(runnable);
return new jbe(runnable);
}
}
}