what-the-bank/sources/androidx/lifecycle/LiveData.java

271 lines
7.1 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package androidx.lifecycle;
import o.C7268clA;
import o.InterfaceC16541pFg;
import o.InterfaceC3451axm;
import o.hFr;
import o.wdQ;
import o.zBc;
/* loaded from: classes.dex */
public abstract class LiveData<T> {
public static final Object c = new Object();
public volatile Object d;
volatile Object f;
private boolean g;
private boolean h;
private final Runnable i;
private boolean j;
private int l;
final Object e = new Object();
public hFr<zBc<? super T>, LiveData<T>.Sts> b = new hFr<>();
public int a = 0;
protected void a() {
}
protected void d() {
}
public LiveData() {
Object obj = c;
this.f = obj;
this.i = new Runnable(this) { // from class: androidx.lifecycle.LiveData.1
final LiveData e;
{
this.e = this;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // java.lang.Runnable
public final void run() {
Object obj2;
synchronized (this.e.e) {
obj2 = this.e.f;
this.e.f = LiveData.c;
}
this.e.a((LiveData) obj2);
}
};
this.d = obj;
this.l = -1;
}
private void a(LiveData<T>.Sts sts) {
if (sts.d) {
if (!sts.e()) {
sts.b(false);
return;
}
int i = sts.e;
int i2 = this.l;
if (i >= i2) {
return;
}
sts.e = i2;
sts.c.onChanged((Object) this.d);
}
}
final void d(LiveData<T>.Sts sts) {
if (this.h) {
this.j = true;
return;
}
this.h = true;
do {
this.j = false;
if (sts != null) {
a((Sts) sts);
sts = null;
} else {
hFr<zBc<? super T>, LiveData<T>.Sts> hfr = this.b;
hFr.IeS ieS = new hFr.IeS(hfr);
hfr.c.put(ieS, Boolean.FALSE);
while (ieS.hasNext()) {
a((Sts) ieS.next().getValue());
if (this.j) {
break;
}
}
}
} while (this.j);
this.h = false;
}
public final void d(InterfaceC16541pFg interfaceC16541pFg, zBc<? super T> zbc) {
e("observe");
if (interfaceC16541pFg.getLifecycle().a() == wdQ.IeS.DESTROYED) {
return;
}
LifecycleBoundObserver lifecycleBoundObserver = new LifecycleBoundObserver(this, interfaceC16541pFg, zbc);
LiveData<T>.Sts a = this.b.a(zbc, lifecycleBoundObserver);
if (a != null && !a.e(interfaceC16541pFg)) {
throw new IllegalArgumentException("Cannot add the same observer with different lifecycles");
}
if (a != null) {
return;
}
interfaceC16541pFg.getLifecycle().e(lifecycleBoundObserver);
}
public void c(zBc<? super T> zbc) {
e("removeObserver");
LiveData<T>.Sts b = this.b.b(zbc);
if (b == null) {
return;
}
b.b();
b.b(false);
}
public void e(T t) {
boolean z;
synchronized (this.e) {
z = this.f == c;
this.f = t;
}
if (z) {
C7268clA.d().c.a(this.i);
}
}
public void a(T t) {
e("setValue");
this.l++;
this.d = t;
d((Sts) null);
}
final void d(int i) {
int i2 = this.a;
this.a = i + i2;
if (this.g) {
return;
}
this.g = true;
while (true) {
try {
int i3 = this.a;
if (i2 == i3) {
return;
}
boolean z = i2 == 0 && i3 > 0;
boolean z2 = i2 > 0 && i3 == 0;
if (z) {
d();
} else if (z2) {
a();
}
i2 = i3;
} finally {
this.g = false;
}
}
}
/* loaded from: classes.dex */
public class LifecycleBoundObserver extends Sts implements InterfaceC3451axm {
final LiveData a;
final InterfaceC16541pFg b;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
LifecycleBoundObserver(LiveData liveData, InterfaceC16541pFg interfaceC16541pFg, zBc<? super T> zbc) {
super(liveData, zbc);
this.a = liveData;
this.b = interfaceC16541pFg;
}
@Override // androidx.lifecycle.LiveData.Sts
final boolean e() {
return this.b.getLifecycle().a().compareTo(wdQ.IeS.STARTED) >= 0;
}
@Override // o.InterfaceC3451axm
public final void c(InterfaceC16541pFg interfaceC16541pFg, wdQ.HBt hBt) {
wdQ.IeS a = this.b.getLifecycle().a();
if (a == wdQ.IeS.DESTROYED) {
this.a.c(this.c);
return;
}
wdQ.IeS ieS = null;
while (ieS != a) {
b(this.b.getLifecycle().a().compareTo(wdQ.IeS.STARTED) >= 0);
ieS = a;
a = this.b.getLifecycle().a();
}
}
@Override // androidx.lifecycle.LiveData.Sts
final void b() {
this.b.getLifecycle().a(this);
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // androidx.lifecycle.LiveData.Sts
public final boolean e(InterfaceC16541pFg interfaceC16541pFg) {
return this.b == interfaceC16541pFg;
}
}
/* loaded from: classes.dex */
public abstract class Sts {
final zBc<? super T> c;
boolean d;
int e = -1;
final LiveData f;
void b() {
}
abstract boolean e();
public boolean e(InterfaceC16541pFg interfaceC16541pFg) {
return false;
}
Sts(LiveData liveData, zBc<? super T> zbc) {
this.f = liveData;
this.c = zbc;
}
public final void b(boolean z) {
if (z == this.d) {
return;
}
this.d = z;
this.f.d(z ? 1 : -1);
if (this.d) {
this.f.d(this);
}
}
}
/* loaded from: classes.dex */
public class HBt extends Sts {
final LiveData a;
@Override // androidx.lifecycle.LiveData.Sts
final boolean e() {
return true;
}
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public HBt(LiveData liveData, zBc<? super T> zbc) {
super(liveData, zbc);
this.a = liveData;
}
}
public static void e(String str) {
if (C7268clA.d().c.c()) {
return;
}
StringBuilder sb = new StringBuilder("Cannot invoke ");
sb.append(str);
sb.append(" on a background thread");
throw new IllegalStateException(sb.toString());
}
}