234 lines
6.8 KiB
Java
234 lines
6.8 KiB
Java
package o;
|
|
|
|
import android.content.Context;
|
|
import android.os.Handler;
|
|
import android.os.SystemClock;
|
|
import androidx.core.os.OperationCanceledException;
|
|
import java.io.FileDescriptor;
|
|
import java.io.PrintWriter;
|
|
import java.util.concurrent.CountDownLatch;
|
|
import java.util.concurrent.Executor;
|
|
|
|
/* renamed from: o.EgC, reason: case insensitive filesystem */
|
|
/* loaded from: classes.dex */
|
|
public abstract class AbstractC0332EgC<D> extends iBO<D> {
|
|
static final boolean DEBUG = false;
|
|
static final String TAG = "AsyncTaskLoader";
|
|
volatile AbstractC0332EgC<D>.IeS mCancellingTask;
|
|
private final Executor mExecutor;
|
|
Handler mHandler;
|
|
long mLastLoadCompleteTime;
|
|
volatile AbstractC0332EgC<D>.IeS mTask;
|
|
long mUpdateThrottle;
|
|
|
|
public void cancelLoadInBackground() {
|
|
}
|
|
|
|
public abstract D loadInBackground();
|
|
|
|
public void onCanceled(D d) {
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: o.EgC$IeS */
|
|
/* loaded from: classes.dex */
|
|
public final class IeS extends AbstractC17450wpZ<Void, Void, D> implements Runnable {
|
|
boolean a;
|
|
final AbstractC0332EgC c;
|
|
private final CountDownLatch h = new CountDownLatch(1);
|
|
|
|
IeS(AbstractC0332EgC abstractC0332EgC) {
|
|
this.c = abstractC0332EgC;
|
|
}
|
|
|
|
@Override // o.AbstractC17450wpZ
|
|
protected final /* synthetic */ Object d(Void[] voidArr) {
|
|
return b();
|
|
}
|
|
|
|
private D b() {
|
|
try {
|
|
return (D) this.c.onLoadInBackground();
|
|
} catch (OperationCanceledException e) {
|
|
if (this.e.get()) {
|
|
return null;
|
|
}
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
@Override // o.AbstractC17450wpZ
|
|
protected final void c(D d) {
|
|
try {
|
|
this.c.dispatchOnLoadComplete(this, d);
|
|
} finally {
|
|
this.h.countDown();
|
|
}
|
|
}
|
|
|
|
@Override // o.AbstractC17450wpZ
|
|
protected final void d(D d) {
|
|
try {
|
|
this.c.dispatchOnCancelled(this, d);
|
|
} finally {
|
|
this.h.countDown();
|
|
}
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
this.a = false;
|
|
this.c.executePendingTask();
|
|
}
|
|
|
|
public final void c() {
|
|
try {
|
|
this.h.await();
|
|
} catch (InterruptedException unused) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public AbstractC0332EgC(Context context) {
|
|
this(context, AbstractC17450wpZ.b);
|
|
}
|
|
|
|
private AbstractC0332EgC(Context context, Executor executor) {
|
|
super(context);
|
|
this.mLastLoadCompleteTime = -10000L;
|
|
this.mExecutor = executor;
|
|
}
|
|
|
|
public void setUpdateThrottle(long j) {
|
|
this.mUpdateThrottle = j;
|
|
if (j != 0) {
|
|
this.mHandler = new Handler();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // o.iBO
|
|
public void onForceLoad() {
|
|
super.onForceLoad();
|
|
cancelLoad();
|
|
this.mTask = new IeS(this);
|
|
executePendingTask();
|
|
}
|
|
|
|
@Override // o.iBO
|
|
protected boolean onCancelLoad() {
|
|
if (this.mTask == null) {
|
|
return false;
|
|
}
|
|
if (!this.mStarted) {
|
|
this.mContentChanged = true;
|
|
}
|
|
if (this.mCancellingTask != null) {
|
|
if (this.mTask.a) {
|
|
this.mTask.a = false;
|
|
this.mHandler.removeCallbacks(this.mTask);
|
|
}
|
|
this.mTask = null;
|
|
return false;
|
|
}
|
|
if (this.mTask.a) {
|
|
this.mTask.a = false;
|
|
this.mHandler.removeCallbacks(this.mTask);
|
|
this.mTask = null;
|
|
return false;
|
|
}
|
|
boolean d = this.mTask.d(false);
|
|
if (d) {
|
|
this.mCancellingTask = this.mTask;
|
|
cancelLoadInBackground();
|
|
}
|
|
this.mTask = null;
|
|
return d;
|
|
}
|
|
|
|
void executePendingTask() {
|
|
if (this.mCancellingTask != null || this.mTask == null) {
|
|
return;
|
|
}
|
|
if (this.mTask.a) {
|
|
this.mTask.a = false;
|
|
this.mHandler.removeCallbacks(this.mTask);
|
|
}
|
|
if (this.mUpdateThrottle > 0 && SystemClock.uptimeMillis() < this.mLastLoadCompleteTime + this.mUpdateThrottle) {
|
|
this.mTask.a = true;
|
|
this.mHandler.postAtTime(this.mTask, this.mLastLoadCompleteTime + this.mUpdateThrottle);
|
|
} else {
|
|
this.mTask.c(this.mExecutor, null);
|
|
}
|
|
}
|
|
|
|
void dispatchOnCancelled(AbstractC0332EgC<D>.IeS ieS, D d) {
|
|
onCanceled(d);
|
|
if (this.mCancellingTask == ieS) {
|
|
rollbackContentChanged();
|
|
this.mLastLoadCompleteTime = SystemClock.uptimeMillis();
|
|
this.mCancellingTask = null;
|
|
deliverCancellation();
|
|
executePendingTask();
|
|
}
|
|
}
|
|
|
|
void dispatchOnLoadComplete(AbstractC0332EgC<D>.IeS ieS, D d) {
|
|
if (this.mTask != ieS) {
|
|
dispatchOnCancelled(ieS, d);
|
|
return;
|
|
}
|
|
if (isAbandoned()) {
|
|
onCanceled(d);
|
|
return;
|
|
}
|
|
commitContentChanged();
|
|
this.mLastLoadCompleteTime = SystemClock.uptimeMillis();
|
|
this.mTask = null;
|
|
deliverResult(d);
|
|
}
|
|
|
|
protected D onLoadInBackground() {
|
|
return loadInBackground();
|
|
}
|
|
|
|
public void waitForLoader() {
|
|
AbstractC0332EgC<D>.IeS ieS = this.mTask;
|
|
if (ieS != null) {
|
|
ieS.c();
|
|
}
|
|
}
|
|
|
|
@Override // o.iBO
|
|
@Deprecated
|
|
public void dump(String str, FileDescriptor fileDescriptor, PrintWriter printWriter, String[] strArr) {
|
|
super.dump(str, fileDescriptor, printWriter, strArr);
|
|
if (this.mTask != null) {
|
|
printWriter.print(str);
|
|
printWriter.print("mTask=");
|
|
printWriter.print(this.mTask);
|
|
printWriter.print(" waiting=");
|
|
printWriter.println(this.mTask.a);
|
|
}
|
|
if (this.mCancellingTask != null) {
|
|
printWriter.print(str);
|
|
printWriter.print("mCancellingTask=");
|
|
printWriter.print(this.mCancellingTask);
|
|
printWriter.print(" waiting=");
|
|
printWriter.println(this.mCancellingTask.a);
|
|
}
|
|
if (this.mUpdateThrottle != 0) {
|
|
printWriter.print(str);
|
|
printWriter.print("mUpdateThrottle=");
|
|
rSm.e(this.mUpdateThrottle, printWriter);
|
|
printWriter.print(" mLastLoadCompleteTime=");
|
|
rSm.a(this.mLastLoadCompleteTime, SystemClock.uptimeMillis(), printWriter);
|
|
printWriter.println();
|
|
}
|
|
}
|
|
|
|
public boolean isLoadInBackgroundCanceled() {
|
|
return this.mCancellingTask != null;
|
|
}
|
|
}
|