SRE/02-Easy5/E5/sources/androidx/lifecycle/LiveDataScopeImpl.java
2025-03-31 16:33:42 +02:00

53 lines
4.0 KiB
Java

package androidx.lifecycle;
import androidx.constraintlayout.core.motion.utils.TypedValues;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.CoroutineContext;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.Dispatchers;
import kotlinx.coroutines.DisposableHandle;
/* compiled from: CoroutineLiveData.kt */
@Metadata(d1 = {"\u00000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0000\u0018\u0000*\u0004\b\u0000\u0010\u00012\b\u0012\u0004\u0012\u0002H\u00010\u0002B\u001b\u0012\f\u0010\u0003\u001a\b\u0012\u0004\u0012\u00028\u00000\u0004\u0012\u0006\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u0007J\u0016\u0010\u0010\u001a\u00020\u00112\u0006\u0010\u0012\u001a\u00028\u0000H\u0097@¢\u0006\u0002\u0010\u0013J\u001c\u0010\u0014\u001a\u00020\u00152\f\u0010\u0016\u001a\b\u0012\u0004\u0012\u00028\u00000\u0017H\u0096@¢\u0006\u0002\u0010\u0018R\u000e\u0010\b\u001a\u00020\u0006X\u0082\u0004¢\u0006\u0002\n\u0000R\u0016\u0010\t\u001a\u0004\u0018\u00018\u00008VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\n\u0010\u000bR \u0010\u0003\u001a\b\u0012\u0004\u0012\u00028\u00000\u0004X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\f\u0010\r\"\u0004\b\u000e\u0010\u000f¨\u0006\u0019"}, d2 = {"Landroidx/lifecycle/LiveDataScopeImpl;", "T", "Landroidx/lifecycle/LiveDataScope;", TypedValues.AttributesType.S_TARGET, "Landroidx/lifecycle/CoroutineLiveData;", "context", "Lkotlin/coroutines/CoroutineContext;", "(Landroidx/lifecycle/CoroutineLiveData;Lkotlin/coroutines/CoroutineContext;)V", "coroutineContext", "latestValue", "getLatestValue", "()Ljava/lang/Object;", "getTarget$lifecycle_livedata_release", "()Landroidx/lifecycle/CoroutineLiveData;", "setTarget$lifecycle_livedata_release", "(Landroidx/lifecycle/CoroutineLiveData;)V", "emit", "", "value", "(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "emitSource", "Lkotlinx/coroutines/DisposableHandle;", "source", "Landroidx/lifecycle/LiveData;", "(Landroidx/lifecycle/LiveData;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "lifecycle-livedata_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public final class LiveDataScopeImpl<T> implements LiveDataScope<T> {
private final CoroutineContext coroutineContext;
private CoroutineLiveData<T> target;
public final CoroutineLiveData<T> getTarget$lifecycle_livedata_release() {
return this.target;
}
public final void setTarget$lifecycle_livedata_release(CoroutineLiveData<T> coroutineLiveData) {
Intrinsics.checkNotNullParameter(coroutineLiveData, "<set-?>");
this.target = coroutineLiveData;
}
public LiveDataScopeImpl(CoroutineLiveData<T> target, CoroutineContext context) {
Intrinsics.checkNotNullParameter(target, "target");
Intrinsics.checkNotNullParameter(context, "context");
this.target = target;
this.coroutineContext = context.plus(Dispatchers.getMain().getImmediate());
}
@Override // androidx.lifecycle.LiveDataScope
public T getLatestValue() {
return this.target.getValue();
}
@Override // androidx.lifecycle.LiveDataScope
public Object emitSource(LiveData<T> liveData, Continuation<? super DisposableHandle> continuation) {
return BuildersKt.withContext(this.coroutineContext, new LiveDataScopeImpl$emitSource$2(this, liveData, null), continuation);
}
@Override // androidx.lifecycle.LiveDataScope
public Object emit(T t, Continuation<? super Unit> continuation) {
Object withContext = BuildersKt.withContext(this.coroutineContext, new LiveDataScopeImpl$emit$2(this, t, null), continuation);
return withContext == IntrinsicsKt.getCOROUTINE_SUSPENDED() ? withContext : Unit.INSTANCE;
}
}