discord-jadx/app/src/main/java/c/o/a/n/v/a.java

121 lines
3.9 KiB
Java

package c.o.a.n.v;
import androidx.annotation.NonNull;
import c.o.a.n.i;
import c.o.a.r.g;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.TaskCompletionSource;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.concurrent.Callable;
/* compiled from: CameraOrchestrator */
public class a {
public static final c.o.a.b a = new c.o.a.b(a.class.getSimpleName());
public final b b;
/* renamed from: c reason: collision with root package name */
public final ArrayDeque<c<?>> f1497c = new ArrayDeque<>();
public boolean d = false;
public final Object e = new Object();
/* compiled from: CameraOrchestrator */
/* renamed from: c.o.a.n.v.a$a reason: collision with other inner class name */
public class CallableC0164a implements Callable<Task<Void>> {
public final /* synthetic */ Runnable i;
public CallableC0164a(a aVar, Runnable runnable) {
this.i = runnable;
}
/* Return type fixed from 'java.lang.Object' to match base method */
@Override // java.util.concurrent.Callable
public Task<Void> call() throws Exception {
this.i.run();
return c.i.a.f.e.o.c.F(null);
}
}
/* compiled from: CameraOrchestrator */
public interface b {
}
/* compiled from: CameraOrchestrator */
public static class c<T> {
public final String a;
public final TaskCompletionSource<T> b = new TaskCompletionSource<>();
/* renamed from: c reason: collision with root package name */
public final Callable<Task<T>> f1498c;
public final boolean d;
public final long e;
public c(String str, Callable callable, boolean z2, long j, CallableC0164a aVar) {
this.a = str;
this.f1498c = callable;
this.d = z2;
this.e = j;
}
}
public a(@NonNull b bVar) {
this.b = bVar;
}
public static void a(a aVar, c cVar) {
if (aVar.d) {
aVar.d = false;
aVar.f1497c.remove(cVar);
g gVar = i.this.j;
gVar.f.postDelayed(new b(aVar), 0);
return;
}
StringBuilder L = c.d.b.a.a.L("mJobRunning was not true after completing job=");
L.append(cVar.a);
throw new IllegalStateException(L.toString());
}
@NonNull
public Task<Void> b(@NonNull String str, boolean z2, @NonNull Runnable runnable) {
return d(str, z2, 0, new CallableC0164a(this, runnable));
}
@NonNull
public Task<Void> c(@NonNull String str, boolean z2, long j, @NonNull Runnable runnable) {
return d(str, z2, j, new CallableC0164a(this, runnable));
}
@NonNull
public final <T> Task<T> d(@NonNull String str, boolean z2, long j, @NonNull Callable<Task<T>> callable) {
a.a(1, str.toUpperCase(), "- Scheduling.");
c<?> cVar = new c<>(str, callable, z2, System.currentTimeMillis() + j, null);
synchronized (this.e) {
this.f1497c.addLast(cVar);
i.this.j.f.postDelayed(new b(this), j);
}
return cVar.b.a;
}
public void e(@NonNull String str, int i) {
synchronized (this.e) {
ArrayList arrayList = new ArrayList();
Iterator<c<?>> it = this.f1497c.iterator();
while (it.hasNext()) {
c<?> next = it.next();
if (next.a.equals(str)) {
arrayList.add(next);
}
}
a.a(0, "trim: name=", str, "scheduled=", Integer.valueOf(arrayList.size()), "allowed=", Integer.valueOf(i));
int max = Math.max(arrayList.size() - i, 0);
if (max > 0) {
Collections.reverse(arrayList);
for (c cVar : arrayList.subList(0, max)) {
this.f1497c.remove(cVar);
}
}
}
}
}