- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
146 lines
5.4 KiB
Java
146 lines
5.4 KiB
Java
package androidx.lifecycle;
|
|
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import androidx.annotation.WorkerThread;
|
|
import androidx.arch.core.executor.ArchTaskExecutor;
|
|
import java.util.concurrent.Executor;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
/* loaded from: classes.dex */
|
|
public abstract class ComputableLiveData<T> {
|
|
private final LiveData<T> _liveData;
|
|
private final AtomicBoolean computing;
|
|
private final Executor executor;
|
|
private final AtomicBoolean invalid;
|
|
public final Runnable invalidationRunnable;
|
|
private final LiveData<T> liveData;
|
|
public final Runnable refreshRunnable;
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public ComputableLiveData() {
|
|
this(null, 1, 0 == true ? 1 : 0);
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public static /* synthetic */ void getInvalidationRunnable$lifecycle_livedata_release$annotations() {
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public static /* synthetic */ void getRefreshRunnable$lifecycle_livedata_release$annotations() {
|
|
}
|
|
|
|
@WorkerThread
|
|
public abstract T compute();
|
|
|
|
public final AtomicBoolean getComputing$lifecycle_livedata_release() {
|
|
return this.computing;
|
|
}
|
|
|
|
public final Executor getExecutor$lifecycle_livedata_release() {
|
|
return this.executor;
|
|
}
|
|
|
|
public final AtomicBoolean getInvalid$lifecycle_livedata_release() {
|
|
return this.invalid;
|
|
}
|
|
|
|
public LiveData<T> getLiveData() {
|
|
return this.liveData;
|
|
}
|
|
|
|
public ComputableLiveData(Executor executor) {
|
|
Intrinsics.checkNotNullParameter(executor, "executor");
|
|
this.executor = executor;
|
|
LiveData<T> liveData = new LiveData<T>(this) { // from class: androidx.lifecycle.ComputableLiveData$_liveData$1
|
|
final /* synthetic */ ComputableLiveData<T> this$0;
|
|
|
|
{
|
|
this.this$0 = this;
|
|
}
|
|
|
|
@Override // androidx.lifecycle.LiveData
|
|
public void onActive() {
|
|
this.this$0.getExecutor$lifecycle_livedata_release().execute(this.this$0.refreshRunnable);
|
|
}
|
|
};
|
|
this._liveData = liveData;
|
|
this.liveData = liveData;
|
|
this.invalid = new AtomicBoolean(true);
|
|
this.computing = new AtomicBoolean(false);
|
|
this.refreshRunnable = new Runnable() { // from class: androidx.lifecycle.ComputableLiveData$$ExternalSyntheticLambda0
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
ComputableLiveData.refreshRunnable$lambda$0(ComputableLiveData.this);
|
|
}
|
|
};
|
|
this.invalidationRunnable = new Runnable() { // from class: androidx.lifecycle.ComputableLiveData$$ExternalSyntheticLambda1
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
ComputableLiveData.invalidationRunnable$lambda$1(ComputableLiveData.this);
|
|
}
|
|
};
|
|
}
|
|
|
|
/* JADX WARN: Illegal instructions before constructor call */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public /* synthetic */ ComputableLiveData(java.util.concurrent.Executor r1, int r2, kotlin.jvm.internal.DefaultConstructorMarker r3) {
|
|
/*
|
|
r0 = this;
|
|
r2 = r2 & 1
|
|
if (r2 == 0) goto Ld
|
|
java.util.concurrent.Executor r1 = androidx.arch.core.executor.ArchTaskExecutor.getIOThreadExecutor()
|
|
java.lang.String r2 = "getIOThreadExecutor()"
|
|
kotlin.jvm.internal.Intrinsics.checkNotNullExpressionValue(r1, r2)
|
|
Ld:
|
|
r0.<init>(r1)
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.lifecycle.ComputableLiveData.<init>(java.util.concurrent.Executor, int, kotlin.jvm.internal.DefaultConstructorMarker):void");
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static final void refreshRunnable$lambda$0(ComputableLiveData this$0) {
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
while (this$0.computing.compareAndSet(false, true)) {
|
|
Object obj = null;
|
|
boolean z = false;
|
|
while (this$0.invalid.compareAndSet(true, false)) {
|
|
try {
|
|
obj = this$0.compute();
|
|
z = true;
|
|
} catch (Throwable th) {
|
|
this$0.computing.set(false);
|
|
throw th;
|
|
}
|
|
}
|
|
if (z) {
|
|
this$0.getLiveData().postValue(obj);
|
|
}
|
|
this$0.computing.set(false);
|
|
if (!z || !this$0.invalid.get()) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static final void invalidationRunnable$lambda$1(ComputableLiveData this$0) {
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
boolean hasActiveObservers = this$0.getLiveData().hasActiveObservers();
|
|
if (this$0.invalid.compareAndSet(false, true) && hasActiveObservers) {
|
|
this$0.executor.execute(this$0.refreshRunnable);
|
|
}
|
|
}
|
|
|
|
public void invalidate() {
|
|
ArchTaskExecutor.getInstance().executeOnMainThread(this.invalidationRunnable);
|
|
}
|
|
}
|