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

276 lines
11 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;
/* compiled from: OnSubscribeFlattenIterable */
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
/* compiled from: OnSubscribeFlattenIterable */
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 final AtomicReference<Throwable> n = new AtomicReference<>();
public final AtomicLong o = new AtomicLong();
public final AtomicInteger p = new AtomicInteger();
public volatile boolean q;
public long r;
/* renamed from: s reason: collision with root package name */
2022-02-10 03:03:45 +00:00
public Iterator<? extends R> f3749s;
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 {
2021-12-17 22:03:14 +00:00
this.l = (long) (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
}
}
request((long) i);
}
public boolean a(boolean z2, boolean z3, Subscriber<?> subscriber, Queue<?> queue) {
if (subscriber.isUnsubscribed()) {
queue.clear();
2022-02-10 03:03:45 +00:00
this.f3749s = 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-02-10 03:03:45 +00:00
this.f3749s = null;
2021-06-27 20:44:35 +00:00
subscriber.onError(h);
return true;
} else if (!z3) {
return false;
} else {
subscriber.onCompleted();
return true;
}
}
}
/* JADX WARNING: Removed duplicated region for block: B:26:0x0066 */
/* JADX WARNING: Removed duplicated region for block: B:49:0x00af */
/* JADX WARNING: Removed duplicated region for block: B:58:0x00c5 */
/* JADX WARNING: Removed duplicated region for block: B:67:0x00cf A[SYNTHETIC] */
/* JADX WARNING: Removed duplicated region for block: B:68:0x00cf A[SYNTHETIC] */
/* JADX WARNING: Removed duplicated region for block: B:70:0x00cc A[SYNTHETIC] */
/* JADX WARNING: Removed duplicated region for block: B:72:0x00d8 A[SYNTHETIC] */
/* JADX WARNING: Removed duplicated region for block: B:75:0x0010 A[SYNTHETIC] */
public void b() {
Iterator<? extends R> it;
int i;
long j;
long j2;
2021-12-17 22:03:14 +00:00
if (this.p.getAndIncrement() == 0) {
Subscriber<? super R> subscriber = this.j;
Queue<?> queue = this.m;
2021-06-27 20:44:35 +00:00
int i2 = 1;
while (true) {
2022-02-10 03:03:45 +00:00
it = this.f3749s;
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) {
2021-12-17 22:03:14 +00:00
long j3 = this.r + 1;
2021-06-27 20:44:35 +00:00
i = i2;
2021-12-17 22:03:14 +00:00
if (j3 == this.l) {
this.r = 0;
2021-06-27 20:44:35 +00:00
request(j3);
} else {
2021-12-17 22:03:14 +00:00
this.r = j3;
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();
2021-06-27 20:44:35 +00:00
if (!it.hasNext()) {
i2 = i;
} else {
2022-02-10 03:03:45 +00:00
this.f3749s = it;
2021-06-27 20:44:35 +00:00
if (it == null) {
2021-12-17 22:03:14 +00:00
j = this.o.get();
2021-06-27 20:44:35 +00:00
j2 = 0;
while (true) {
if (j2 == j) {
break;
2021-12-17 22:03:14 +00:00
} else if (!a(this.q, false, subscriber, queue)) {
2021-06-27 20:44:35 +00:00
try {
subscriber.onNext((Object) it.next());
2021-12-17 22:03:14 +00:00
if (!a(this.q, false, subscriber, queue)) {
2021-06-27 20:44:35 +00:00
j2++;
try {
if (!it.hasNext()) {
2022-02-10 03:03:45 +00:00
this.f3749s = null;
2021-06-27 20:44:35 +00:00
break;
}
} catch (Throwable th) {
2022-01-27 00:50:41 +00:00
f.o1(th);
2022-02-10 03:03:45 +00:00
this.f3749s = null;
2021-06-27 20:44:35 +00:00
onError(th);
}
} else {
return;
}
} catch (Throwable th2) {
2022-01-27 00:50:41 +00:00
f.o1(th2);
2022-02-10 03:03:45 +00:00
this.f3749s = null;
2021-06-27 20:44:35 +00:00
onError(th2);
}
} else {
return;
}
}
if (j2 == j) {
2021-12-17 22:03:14 +00:00
boolean z5 = this.q;
2021-06-27 20:44:35 +00:00
if (queue.isEmpty() && it == null) {
z2 = true;
}
if (a(z5, z2, subscriber, queue)) {
return;
}
}
if (j2 != 0) {
2022-01-27 00:50:41 +00:00
f.U0(this.o, j2);
2021-06-27 20:44:35 +00:00
}
if (it != null) {
i2 = i;
}
}
2021-12-17 22:03:14 +00:00
i2 = this.p.addAndGet(-i);
2021-06-27 20:44:35 +00:00
if (i2 != 0) {
return;
}
}
} catch (Throwable th3) {
2022-01-27 00:50:41 +00:00
f.o1(th3);
2021-06-27 20:44:35 +00:00
onError(th3);
}
}
} else {
return;
}
}
i = i2;
if (it == null) {
}
2021-12-17 22:03:14 +00:00
i2 = this.p.addAndGet(-i);
2021-06-27 20:44:35 +00:00
if (i2 != 0) {
}
}
} else {
return;
}
it = null;
if (j2 == j) {
}
if (j2 != 0) {
}
if (it != null) {
}
}
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-02-10 03:03:45 +00:00
t = (T) e.f3743b;
2021-06-27 20:44:35 +00:00
}
if (!queue.offer(t)) {
unsubscribe();
onError(new MissingBackpressureException());
return;
}
b();
}
}
/* compiled from: OnSubscribeFlattenIterable */
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 {
2021-12-17 22:03:14 +00:00
Iterator<T> it = ((Iterable) this.k.call(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
}
}