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

261 lines
10 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;
2022-01-27 00:50:41 +00:00
import b.i.a.f.e.o.f;
2021-11-08 18:25:28 +00:00
import j0.l.a.q;
import j0.l.e.d;
2021-12-17 22:03:14 +00:00
import j0.l.e.i;
import j0.l.e.n.c;
import j0.l.e.n.e;
import j0.l.e.o.y;
2021-11-08 18:25:28 +00:00
import j0.o.l;
2021-06-27 20:44:35 +00:00
import java.util.Iterator;
import java.util.Queue;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import rx.Observable;
import rx.Subscriber;
import rx.exceptions.MissingBackpressureException;
2022-03-02 20:59:20 +00:00
/* compiled from: OnSubscribeFlattenIterable.java */
/* loaded from: classes3.dex */
2021-06-27 20:44:35 +00:00
public final class n<T, R> implements Observable.a<R> {
2021-12-17 22:03:14 +00:00
public final Observable<? extends T> j;
public final j0.k.b<? super T, ? extends Iterable<? extends R>> k;
public final int l;
2021-06-27 20:44:35 +00:00
2022-03-02 20:59:20 +00:00
/* compiled from: OnSubscribeFlattenIterable.java */
/* loaded from: classes3.dex */
2021-06-27 20:44:35 +00:00
public static final class a<T, R> extends Subscriber<T> {
2021-12-17 22:03:14 +00:00
public final Subscriber<? super R> j;
public final j0.k.b<? super T, ? extends Iterable<? extends R>> k;
public final long l;
public final Queue<Object> m;
public volatile boolean q;
public long r;
/* renamed from: s reason: collision with root package name */
2022-03-30 16:43:10 +00:00
public Iterator<? extends R> f3759s;
2022-03-02 20:59:20 +00:00
public final AtomicReference<Throwable> n = new AtomicReference<>();
public final AtomicInteger p = new AtomicInteger();
public final AtomicLong o = new AtomicLong();
2021-06-27 20:44:35 +00:00
2021-11-08 18:25:28 +00:00
public a(Subscriber<? super R> subscriber, j0.k.b<? super T, ? extends Iterable<? extends R>> bVar, int i) {
2021-12-17 22:03:14 +00:00
this.j = subscriber;
this.k = bVar;
2021-06-27 20:44:35 +00:00
if (i == Integer.MAX_VALUE) {
2021-12-17 22:03:14 +00:00
this.l = RecyclerView.FOREVER_NS;
this.m = new e(i.j);
2021-06-27 20:44:35 +00:00
} else {
2022-03-02 20:59:20 +00:00
this.l = i - (i >> 2);
2021-06-27 20:44:35 +00:00
if (y.b()) {
2021-12-17 22:03:14 +00:00
this.m = new j0.l.e.o.n(i);
2021-06-27 20:44:35 +00:00
} else {
2021-12-17 22:03:14 +00:00
this.m = new c(i);
2021-06-27 20:44:35 +00:00
}
}
2022-03-02 20:59:20 +00:00
request(i);
2021-06-27 20:44:35 +00:00
}
public boolean a(boolean z2, boolean z3, Subscriber<?> subscriber, Queue<?> queue) {
if (subscriber.isUnsubscribed()) {
queue.clear();
2022-03-30 16:43:10 +00:00
this.f3759s = null;
2021-06-27 20:44:35 +00:00
return true;
} else if (!z2) {
return false;
} else {
2021-12-17 22:03:14 +00:00
if (this.n.get() != null) {
Throwable h = d.h(this.n);
2021-06-27 20:44:35 +00:00
unsubscribe();
queue.clear();
2022-03-30 16:43:10 +00:00
this.f3759s = null;
2021-06-27 20:44:35 +00:00
subscriber.onError(h);
return true;
} else if (!z3) {
return false;
} else {
subscriber.onCompleted();
return true;
}
}
}
2022-03-02 20:59:20 +00:00
/* JADX WARN: Removed duplicated region for block: B:27:0x0066 */
/* JADX WARN: Removed duplicated region for block: B:73:0x00cf A[SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:77:0x00d8 A[SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:80:0x0010 A[SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
*/
2021-06-27 20:44:35 +00:00
public void b() {
2021-12-17 22:03:14 +00:00
if (this.p.getAndIncrement() == 0) {
Subscriber<? super R> subscriber = this.j;
Queue<?> queue = this.m;
2022-03-02 20:59:20 +00:00
int i = 1;
2021-06-27 20:44:35 +00:00
while (true) {
2022-03-30 16:43:10 +00:00
Iterator<? extends R> it = this.f3759s;
2021-06-27 20:44:35 +00:00
boolean z2 = false;
if (it == null) {
2021-12-17 22:03:14 +00:00
boolean z3 = this.q;
2021-06-27 20:44:35 +00:00
Object poll = queue.poll();
boolean z4 = poll == null;
if (!a(z3, z4, subscriber, queue)) {
if (!z4) {
2022-03-02 20:59:20 +00:00
long j = this.r + 1;
i = i;
if (j == this.l) {
this.r = 0L;
request(j);
2021-06-27 20:44:35 +00:00
} else {
2022-03-02 20:59:20 +00:00
this.r = j;
2021-06-27 20:44:35 +00:00
}
try {
2021-12-17 22:03:14 +00:00
it = ((Iterable) this.k.call((Object) e.b(poll))).iterator();
2022-03-02 20:59:20 +00:00
} catch (Throwable th) {
f.o1(th);
onError(th);
}
if (it.hasNext()) {
2022-03-30 16:43:10 +00:00
this.f3759s = it;
2022-03-02 20:59:20 +00:00
if (it == null) {
long j2 = this.o.get();
long j3 = 0;
while (j3 != j2) {
if (!a(this.q, false, subscriber, queue)) {
try {
subscriber.onNext((Object) it.next());
} catch (Throwable th2) {
f.o1(th2);
2022-03-30 16:43:10 +00:00
this.f3759s = null;
2022-03-02 20:59:20 +00:00
onError(th2);
}
if (!a(this.q, false, subscriber, queue)) {
j3++;
2021-06-27 20:44:35 +00:00
try {
2022-03-02 20:59:20 +00:00
} catch (Throwable th3) {
f.o1(th3);
2022-03-30 16:43:10 +00:00
this.f3759s = null;
2022-03-02 20:59:20 +00:00
onError(th3);
}
if (!it.hasNext()) {
2022-03-30 16:43:10 +00:00
this.f3759s = null;
2022-03-02 20:59:20 +00:00
it = null;
break;
2021-06-27 20:44:35 +00:00
}
} else {
return;
}
2022-03-02 20:59:20 +00:00
} else {
return;
2021-06-27 20:44:35 +00:00
}
2022-03-02 20:59:20 +00:00
}
if (j3 == j2) {
boolean z5 = this.q;
if (queue.isEmpty() && it == null) {
z2 = true;
2021-06-27 20:44:35 +00:00
}
2022-03-02 20:59:20 +00:00
if (a(z5, z2, subscriber, queue)) {
return;
2021-06-27 20:44:35 +00:00
}
}
2022-03-02 20:59:20 +00:00
if (j3 != 0) {
f.U0(this.o, j3);
2021-06-27 20:44:35 +00:00
}
2022-03-02 20:59:20 +00:00
if (it == null) {
}
}
i = this.p.addAndGet(-i);
if (i != 0) {
return;
2021-06-27 20:44:35 +00:00
}
}
}
} else {
return;
}
}
2022-03-02 20:59:20 +00:00
i = i;
2021-06-27 20:44:35 +00:00
if (it == null) {
}
2022-03-02 20:59:20 +00:00
i = this.p.addAndGet(-i);
if (i != 0) {
2021-06-27 20:44:35 +00:00
}
}
}
}
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
if (d.f(this.n, th)) {
this.q = true;
2021-06-27 20:44:35 +00:00
b();
return;
}
l.b(th);
}
2021-11-08 18:25:28 +00:00
@Override // j0.g
2021-06-27 20:44:35 +00:00
public void onNext(T t) {
2021-12-17 22:03:14 +00:00
Queue<Object> queue = this.m;
2021-06-27 20:44:35 +00:00
if (t == null) {
2022-03-30 16:43:10 +00:00
t = (T) e.f3753b;
2021-06-27 20:44:35 +00:00
}
if (!queue.offer(t)) {
unsubscribe();
onError(new MissingBackpressureException());
return;
}
b();
}
}
2022-03-02 20:59:20 +00:00
/* compiled from: OnSubscribeFlattenIterable.java */
/* loaded from: classes3.dex */
2021-06-27 20:44:35 +00:00
public static final class b<T, R> implements Observable.a<R> {
2021-12-17 22:03:14 +00:00
public final T j;
public final j0.k.b<? super T, ? extends Iterable<? extends R>> k;
2021-06-27 20:44:35 +00:00
2021-11-08 18:25:28 +00:00
public b(T t, j0.k.b<? super T, ? extends Iterable<? extends R>> bVar) {
2021-12-17 22:03:14 +00:00
this.j = t;
this.k = bVar;
2021-06-27 20:44:35 +00:00
}
@Override // rx.functions.Action1
public void call(Object obj) {
Subscriber subscriber = (Subscriber) obj;
try {
2022-03-02 20:59:20 +00:00
Iterator<T> it = ((Iterable) this.k.call((T) this.j)).iterator();
2021-06-27 20:44:35 +00:00
if (!it.hasNext()) {
subscriber.onCompleted();
} else {
subscriber.setProducer(new q.a(subscriber, it));
}
} catch (Throwable th) {
2022-01-27 00:50:41 +00:00
f.p1(th, subscriber, this.j);
2021-06-27 20:44:35 +00:00
}
}
}
2021-11-08 18:25:28 +00:00
public n(Observable<? extends T> observable, j0.k.b<? super T, ? extends Iterable<? extends R>> bVar, int i) {
2021-12-17 22:03:14 +00:00
this.j = observable;
this.k = bVar;
this.l = i;
2021-06-27 20:44:35 +00:00
}
@Override // rx.functions.Action1
public void call(Object obj) {
Subscriber subscriber = (Subscriber) obj;
2021-12-17 22:03:14 +00:00
a aVar = new a(subscriber, this.k, this.l);
2021-06-27 20:44:35 +00:00
subscriber.add(aVar);
subscriber.setProducer(new m(this, aVar));
2021-12-17 22:03:14 +00:00
this.j.i0(aVar);
2021-06-27 20:44:35 +00:00
}
}