discord-jadx/app/src/main/java/j0/l/a/o1.java

190 lines
5.7 KiB
Java
Raw Normal View History

2021-11-08 18:25:28 +00:00
package j0.l.a;
2021-06-27 20:44:35 +00:00
import androidx.recyclerview.widget.RecyclerView;
2021-11-08 18:25:28 +00:00
import j0.g;
2021-12-17 22:03:14 +00:00
import j0.l.e.n.f;
import j0.l.e.o.s;
import j0.l.e.o.y;
2021-06-27 20:44:35 +00:00
import java.util.Queue;
import java.util.concurrent.atomic.AtomicLong;
import rx.Observable;
import rx.Producer;
import rx.Subscriber;
import rx.functions.Func0;
import rx.functions.Func2;
2022-03-02 20:59:20 +00:00
/* compiled from: OperatorScan.java */
/* loaded from: classes3.dex */
2021-06-27 20:44:35 +00:00
public final class o1<R, T> implements Observable.b<R, T> {
2021-12-17 22:03:14 +00:00
public static final Object j = new Object();
public final Func0<R> k;
public final Func2<R, ? super T, R> l;
2021-06-27 20:44:35 +00:00
2022-03-02 20:59:20 +00:00
/* compiled from: OperatorScan.java */
/* loaded from: classes3.dex */
2021-06-27 20:44:35 +00:00
public class a implements Func0<R> {
2021-12-17 22:03:14 +00:00
public final /* synthetic */ Object j;
2021-06-27 20:44:35 +00:00
public a(Object obj) {
2021-12-17 22:03:14 +00:00
this.j = obj;
2021-06-27 20:44:35 +00:00
}
@Override // rx.functions.Func0, java.util.concurrent.Callable
public R call() {
2021-12-17 22:03:14 +00:00
return (R) this.j;
2021-06-27 20:44:35 +00:00
}
}
2022-03-02 20:59:20 +00:00
/* compiled from: OperatorScan.java */
/* loaded from: classes3.dex */
2021-06-27 20:44:35 +00:00
public static final class b<R> implements Producer, g<R> {
2021-12-17 22:03:14 +00:00
public final Subscriber<? super R> j;
public final Queue<Object> k;
2021-06-27 20:44:35 +00:00
public boolean l;
2021-12-17 22:03:14 +00:00
public boolean m;
public long n;
public final AtomicLong o;
public volatile Producer p;
public volatile boolean q;
public Throwable r;
2021-06-27 20:44:35 +00:00
2021-11-08 18:25:28 +00:00
public b(R r, Subscriber<? super R> subscriber) {
2021-12-17 22:03:14 +00:00
this.j = subscriber;
2021-06-27 20:44:35 +00:00
Queue<Object> sVar = y.b() ? new s<>() : new f<>();
2021-12-17 22:03:14 +00:00
this.k = sVar;
2022-03-22 15:40:06 +00:00
sVar.offer(r == null ? (R) e.f3749b : r);
2021-12-17 22:03:14 +00:00
this.o = new AtomicLong();
2021-06-27 20:44:35 +00:00
}
public boolean a(boolean z2, boolean z3, Subscriber<? super R> subscriber) {
if (subscriber.isUnsubscribed()) {
return true;
}
if (!z2) {
return false;
}
2021-12-17 22:03:14 +00:00
Throwable th = this.r;
2021-06-27 20:44:35 +00:00
if (th != null) {
subscriber.onError(th);
return true;
} else if (!z3) {
return false;
} else {
subscriber.onCompleted();
return true;
}
}
public void b() {
synchronized (this) {
2021-12-17 22:03:14 +00:00
if (this.l) {
this.m = true;
2021-06-27 20:44:35 +00:00
return;
}
2021-12-17 22:03:14 +00:00
this.l = true;
2022-03-02 20:59:20 +00:00
Subscriber<? super R> subscriber = this.j;
Queue<Object> queue = this.k;
AtomicLong atomicLong = this.o;
long j = atomicLong.get();
while (!a(this.q, queue.isEmpty(), subscriber)) {
long j2 = 0;
while (j2 != j) {
boolean z2 = this.q;
Object poll = queue.poll();
boolean z3 = poll == null;
if (!a(z2, z3, subscriber)) {
if (z3) {
break;
}
Object obj = (Object) e.b(poll);
try {
subscriber.onNext(obj);
j2++;
} catch (Throwable th) {
b.i.a.f.e.o.f.p1(th, subscriber, obj);
return;
}
} else {
2021-06-27 20:44:35 +00:00
return;
}
}
2022-03-02 20:59:20 +00:00
if (!(j2 == 0 || j == RecyclerView.FOREVER_NS)) {
j = b.i.a.f.e.o.f.U0(atomicLong, j2);
}
synchronized (this) {
if (!this.m) {
this.l = false;
return;
}
this.m = false;
2021-06-27 20:44:35 +00:00
}
}
}
}
@Override // rx.Producer
public void j(long j) {
2022-03-02 20:59:20 +00:00
int i = (j > 0L ? 1 : (j == 0L ? 0 : -1));
2021-06-27 20:44:35 +00:00
if (i < 0) {
2021-12-21 23:37:30 +00:00
throw new IllegalArgumentException(b.d.b.a.a.s("n >= required but it was ", j));
2021-06-27 20:44:35 +00:00
} else if (i != 0) {
2022-01-27 00:50:41 +00:00
b.i.a.f.e.o.f.c0(this.o, j);
2021-12-17 22:03:14 +00:00
Producer producer = this.p;
2021-06-27 20:44:35 +00:00
if (producer == null) {
2021-12-17 22:03:14 +00:00
synchronized (this.o) {
producer = this.p;
2021-06-27 20:44:35 +00:00
if (producer == null) {
2022-01-27 00:50:41 +00:00
this.n = b.i.a.f.e.o.f.f(this.n, j);
2021-06-27 20:44:35 +00:00
}
}
}
if (producer != null) {
producer.j(j);
}
b();
}
}
2021-11-08 18:25:28 +00:00
@Override // j0.g
2021-06-27 20:44:35 +00:00
public void onCompleted() {
2021-12-17 22:03:14 +00:00
this.q = true;
2021-06-27 20:44:35 +00:00
b();
}
2021-11-08 18:25:28 +00:00
@Override // j0.g
2021-06-27 20:44:35 +00:00
public void onError(Throwable th) {
2021-12-17 22:03:14 +00:00
this.r = th;
this.q = true;
2021-06-27 20:44:35 +00:00
b();
}
2021-11-08 18:25:28 +00:00
@Override // j0.g
public void onNext(R r) {
2021-12-17 22:03:14 +00:00
Queue<Object> queue = this.k;
2021-11-08 18:25:28 +00:00
if (r == null) {
2022-03-22 15:40:06 +00:00
r = (R) e.f3749b;
2021-06-27 20:44:35 +00:00
}
2021-11-08 18:25:28 +00:00
queue.offer(r);
2021-06-27 20:44:35 +00:00
b();
}
}
2021-11-08 18:25:28 +00:00
public o1(R r, Func2<R, ? super T, R> func2) {
2021-12-17 22:03:14 +00:00
this.k = new a(r);
this.l = func2;
2021-06-27 20:44:35 +00:00
}
2021-11-08 18:25:28 +00:00
@Override // j0.k.b
2021-06-27 20:44:35 +00:00
public Object call(Object obj) {
Subscriber subscriber = (Subscriber) obj;
2021-12-17 22:03:14 +00:00
R call = this.k.call();
if (call == j) {
2021-06-27 20:44:35 +00:00
return new p1(this, subscriber, subscriber);
}
b bVar = new b(call, subscriber);
q1 q1Var = new q1(this, call, bVar);
subscriber.add(q1Var);
subscriber.setProducer(bVar);
return q1Var;
}
}