2021-06-27 20:44:35 +00:00
|
|
|
package androidx.lifecycle;
|
|
|
|
|
2021-12-21 23:37:30 +00:00
|
|
|
import b.i.a.f.e.o.f;
|
2021-11-08 18:25:28 +00:00
|
|
|
import d0.l;
|
|
|
|
import d0.w.h.c;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import d0.z.d.o;
|
2021-06-27 20:44:35 +00:00
|
|
|
import kotlin.Unit;
|
|
|
|
import kotlin.coroutines.Continuation;
|
|
|
|
import kotlin.coroutines.CoroutineContext;
|
|
|
|
import kotlin.jvm.functions.Function0;
|
|
|
|
import kotlin.jvm.functions.Function2;
|
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
2021-07-09 21:07:36 +00:00
|
|
|
import kotlinx.coroutines.CoroutineDispatcher;
|
2021-06-27 20:44:35 +00:00
|
|
|
import kotlinx.coroutines.Job;
|
2021-11-08 18:25:28 +00:00
|
|
|
import s.a.a.n;
|
2021-12-17 22:03:14 +00:00
|
|
|
import s.a.k0;
|
|
|
|
import s.a.m0;
|
|
|
|
import s.a.t1;
|
2021-06-27 20:44:35 +00:00
|
|
|
/* compiled from: CoroutineLiveData.kt */
|
|
|
|
public final class CoroutineLiveData<T> extends MediatorLiveData<T> {
|
|
|
|
private BlockRunner<T> blockRunner;
|
|
|
|
private EmittedSource emittedSource;
|
|
|
|
|
|
|
|
/* compiled from: CoroutineLiveData.kt */
|
|
|
|
/* renamed from: androidx.lifecycle.CoroutineLiveData$1 reason: invalid class name */
|
|
|
|
public static final class AnonymousClass1 extends o implements Function0<Unit> {
|
|
|
|
public final /* synthetic */ CoroutineLiveData this$0;
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public AnonymousClass1(CoroutineLiveData coroutineLiveData) {
|
|
|
|
super(0);
|
|
|
|
this.this$0 = coroutineLiveData;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // kotlin.jvm.functions.Function0
|
|
|
|
/* renamed from: invoke */
|
2021-11-08 18:25:28 +00:00
|
|
|
public final void mo1invoke() {
|
2021-06-27 20:44:35 +00:00
|
|
|
CoroutineLiveData.access$setBlockRunner$p(this.this$0, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public CoroutineLiveData(CoroutineContext coroutineContext, long j, Function2<? super LiveDataScope<T>, ? super Continuation<? super Unit>, ? extends Object> function2) {
|
|
|
|
m.checkNotNullParameter(coroutineContext, "context");
|
|
|
|
m.checkNotNullParameter(function2, "block");
|
2021-12-17 22:03:14 +00:00
|
|
|
t1 t1Var = new t1((Job) coroutineContext.get(Job.h));
|
|
|
|
CoroutineDispatcher coroutineDispatcher = k0.a;
|
2022-02-14 21:43:51 +00:00
|
|
|
this.blockRunner = new BlockRunner<>(this, function2, j, f.c(n.f3806b.H().plus(coroutineContext).plus(t1Var)), new AnonymousClass1(this));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
|
|
public /* synthetic */ CoroutineLiveData(CoroutineContext coroutineContext, long j, Function2 function2, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
2021-12-17 22:03:14 +00:00
|
|
|
this((i & 1) != 0 ? d0.w.f.j : coroutineContext, (i & 2) != 0 ? 5000 : j, function2);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ BlockRunner access$getBlockRunner$p(CoroutineLiveData coroutineLiveData) {
|
|
|
|
return coroutineLiveData.blockRunner;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$setBlockRunner$p(CoroutineLiveData coroutineLiveData, BlockRunner blockRunner) {
|
|
|
|
coroutineLiveData.blockRunner = blockRunner;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:12:0x0035 */
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:8:0x0023 */
|
|
|
|
public final Object clearSource$lifecycle_livedata_ktx_release(Continuation<? super Unit> continuation) {
|
|
|
|
CoroutineLiveData$clearSource$1 coroutineLiveData$clearSource$1;
|
|
|
|
int i;
|
|
|
|
CoroutineLiveData<T> coroutineLiveData;
|
|
|
|
if (continuation instanceof CoroutineLiveData$clearSource$1) {
|
|
|
|
coroutineLiveData$clearSource$1 = (CoroutineLiveData$clearSource$1) continuation;
|
|
|
|
int i2 = coroutineLiveData$clearSource$1.label;
|
|
|
|
if ((i2 & Integer.MIN_VALUE) != 0) {
|
|
|
|
coroutineLiveData$clearSource$1.label = i2 - Integer.MIN_VALUE;
|
|
|
|
Object obj = coroutineLiveData$clearSource$1.result;
|
|
|
|
Object coroutine_suspended = c.getCOROUTINE_SUSPENDED();
|
|
|
|
i = coroutineLiveData$clearSource$1.label;
|
|
|
|
if (i != 0) {
|
|
|
|
l.throwOnFailure(obj);
|
|
|
|
EmittedSource emittedSource = this.emittedSource;
|
|
|
|
if (emittedSource != null) {
|
|
|
|
coroutineLiveData$clearSource$1.L$0 = this;
|
|
|
|
coroutineLiveData$clearSource$1.label = 1;
|
|
|
|
if (emittedSource.disposeNow(coroutineLiveData$clearSource$1) == coroutine_suspended) {
|
|
|
|
return coroutine_suspended;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
coroutineLiveData = this;
|
|
|
|
} else if (i == 1) {
|
|
|
|
coroutineLiveData = (CoroutineLiveData) coroutineLiveData$clearSource$1.L$0;
|
|
|
|
l.throwOnFailure(obj);
|
|
|
|
} else {
|
|
|
|
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
|
|
|
|
}
|
|
|
|
coroutineLiveData.emittedSource = null;
|
|
|
|
return Unit.a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
coroutineLiveData$clearSource$1 = new CoroutineLiveData$clearSource$1(this, continuation);
|
|
|
|
Object obj = coroutineLiveData$clearSource$1.result;
|
|
|
|
Object coroutine_suspended = c.getCOROUTINE_SUSPENDED();
|
|
|
|
i = coroutineLiveData$clearSource$1.label;
|
|
|
|
if (i != 0) {
|
|
|
|
}
|
|
|
|
coroutineLiveData.emittedSource = null;
|
|
|
|
return Unit.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:14:0x0046 */
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:20:0x0065 A[RETURN] */
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:8:0x0024 */
|
2021-12-17 22:03:14 +00:00
|
|
|
public final Object emitSource$lifecycle_livedata_ktx_release(LiveData<T> liveData, Continuation<? super m0> continuation) {
|
2021-06-27 20:44:35 +00:00
|
|
|
CoroutineLiveData$emitSource$1 coroutineLiveData$emitSource$1;
|
|
|
|
Object obj;
|
|
|
|
Object coroutine_suspended;
|
|
|
|
int i;
|
|
|
|
CoroutineLiveData<T> coroutineLiveData;
|
|
|
|
LiveData<T> liveData2;
|
|
|
|
if (continuation instanceof CoroutineLiveData$emitSource$1) {
|
|
|
|
coroutineLiveData$emitSource$1 = (CoroutineLiveData$emitSource$1) continuation;
|
|
|
|
int i2 = coroutineLiveData$emitSource$1.label;
|
|
|
|
if ((i2 & Integer.MIN_VALUE) != 0) {
|
|
|
|
coroutineLiveData$emitSource$1.label = i2 - Integer.MIN_VALUE;
|
|
|
|
obj = coroutineLiveData$emitSource$1.result;
|
|
|
|
coroutine_suspended = c.getCOROUTINE_SUSPENDED();
|
|
|
|
i = coroutineLiveData$emitSource$1.label;
|
|
|
|
if (i != 0) {
|
|
|
|
l.throwOnFailure(obj);
|
|
|
|
coroutineLiveData$emitSource$1.L$0 = this;
|
|
|
|
coroutineLiveData$emitSource$1.L$1 = liveData;
|
|
|
|
coroutineLiveData$emitSource$1.label = 1;
|
|
|
|
if (clearSource$lifecycle_livedata_ktx_release(coroutineLiveData$emitSource$1) == coroutine_suspended) {
|
|
|
|
return coroutine_suspended;
|
|
|
|
}
|
|
|
|
liveData2 = liveData;
|
|
|
|
coroutineLiveData = this;
|
|
|
|
} else if (i == 1) {
|
|
|
|
l.throwOnFailure(obj);
|
|
|
|
liveData2 = (LiveData) coroutineLiveData$emitSource$1.L$1;
|
|
|
|
coroutineLiveData = (CoroutineLiveData) coroutineLiveData$emitSource$1.L$0;
|
|
|
|
} else if (i == 2) {
|
|
|
|
coroutineLiveData = (CoroutineLiveData) coroutineLiveData$emitSource$1.L$0;
|
|
|
|
l.throwOnFailure(obj);
|
|
|
|
EmittedSource emittedSource = (EmittedSource) obj;
|
|
|
|
coroutineLiveData.emittedSource = emittedSource;
|
|
|
|
return emittedSource;
|
|
|
|
} else {
|
|
|
|
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
|
|
|
|
}
|
|
|
|
coroutineLiveData$emitSource$1.L$0 = coroutineLiveData;
|
|
|
|
coroutineLiveData$emitSource$1.L$1 = null;
|
|
|
|
coroutineLiveData$emitSource$1.label = 2;
|
|
|
|
obj = CoroutineLiveDataKt.addDisposableSource(coroutineLiveData, liveData2, coroutineLiveData$emitSource$1);
|
|
|
|
if (obj == coroutine_suspended) {
|
|
|
|
return coroutine_suspended;
|
|
|
|
}
|
|
|
|
EmittedSource emittedSource = (EmittedSource) obj;
|
|
|
|
coroutineLiveData.emittedSource = emittedSource;
|
|
|
|
return emittedSource;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
coroutineLiveData$emitSource$1 = new CoroutineLiveData$emitSource$1(this, continuation);
|
|
|
|
obj = coroutineLiveData$emitSource$1.result;
|
|
|
|
coroutine_suspended = c.getCOROUTINE_SUSPENDED();
|
|
|
|
i = coroutineLiveData$emitSource$1.label;
|
|
|
|
if (i != 0) {
|
|
|
|
}
|
|
|
|
coroutineLiveData$emitSource$1.L$0 = coroutineLiveData;
|
|
|
|
coroutineLiveData$emitSource$1.L$1 = null;
|
|
|
|
coroutineLiveData$emitSource$1.label = 2;
|
|
|
|
obj = CoroutineLiveDataKt.addDisposableSource(coroutineLiveData, liveData2, coroutineLiveData$emitSource$1);
|
|
|
|
if (obj == coroutine_suspended) {
|
|
|
|
}
|
|
|
|
EmittedSource emittedSource = (EmittedSource) obj;
|
|
|
|
coroutineLiveData.emittedSource = emittedSource;
|
|
|
|
return emittedSource;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.lifecycle.MediatorLiveData, androidx.lifecycle.LiveData
|
|
|
|
public void onActive() {
|
|
|
|
super.onActive();
|
|
|
|
BlockRunner<T> blockRunner = this.blockRunner;
|
|
|
|
if (blockRunner != null) {
|
|
|
|
blockRunner.maybeRun();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.lifecycle.MediatorLiveData, androidx.lifecycle.LiveData
|
|
|
|
public void onInactive() {
|
|
|
|
super.onInactive();
|
|
|
|
BlockRunner<T> blockRunner = this.blockRunner;
|
|
|
|
if (blockRunner != null) {
|
|
|
|
blockRunner.cancel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|