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

656 lines
21 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.l.a.e;
2021-06-27 20:44:35 +00:00
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import rx.Observable;
import rx.Producer;
import rx.Subscriber;
import rx.Subscription;
import rx.exceptions.OnErrorThrowable;
import rx.functions.Action1;
import rx.functions.Func0;
/* compiled from: OperatorReplay */
2021-11-08 18:25:28 +00:00
public final class j1<T> extends j0.m.b<T> implements Subscription {
2021-06-27 20:44:35 +00:00
public static final Func0 j = new a();
public final Observable<? extends T> k;
public final AtomicReference<f<T>> l;
public final Func0<? extends e<T>> m;
/* compiled from: OperatorReplay */
public static class a implements Func0 {
@Override // rx.functions.Func0, java.util.concurrent.Callable
public Object call() {
return new h(16);
}
}
/* compiled from: OperatorReplay */
public static class b<T> extends AtomicReference<d> implements e<T> {
private static final long serialVersionUID = 2346567790059478686L;
public long index;
public int size;
public d tail;
public b() {
d dVar = new d(null, 0);
this.tail = dVar;
set(dVar);
}
public void a() {
}
2021-11-08 18:25:28 +00:00
@Override // j0.l.a.j1.e
2021-06-27 20:44:35 +00:00
public final void complete() {
Object obj = e.a;
long j = this.index + 1;
this.index = j;
d dVar = new d(obj, j);
this.tail.set(dVar);
this.tail = dVar;
this.size++;
}
2021-11-08 18:25:28 +00:00
@Override // j0.l.a.j1.e
2021-06-27 20:44:35 +00:00
public final void g(T t) {
if (t == null) {
t = (T) e.b;
}
long j = this.index + 1;
this.index = j;
d dVar = new d(t, j);
this.tail.set(dVar);
this.tail = dVar;
this.size++;
a();
}
2021-11-08 18:25:28 +00:00
@Override // j0.l.a.j1.e
2021-06-27 20:44:35 +00:00
public final void h(c<T> cVar) {
Subscriber<? super T> subscriber;
d dVar;
synchronized (cVar) {
if (cVar.emitting) {
cVar.missed = true;
return;
}
cVar.emitting = true;
}
while (!cVar.isUnsubscribed()) {
d dVar2 = (d) cVar.index;
if (dVar2 == null) {
dVar2 = get();
cVar.index = dVar2;
cVar.a(dVar2.index);
}
if (!cVar.isUnsubscribed() && (subscriber = cVar.child) != null) {
long j = cVar.get();
long j2 = 0;
while (j2 != j && (dVar = dVar2.get()) != null) {
Object obj = dVar.value;
try {
if (e.a(subscriber, obj)) {
cVar.index = null;
return;
}
j2++;
if (!cVar.isUnsubscribed()) {
dVar2 = dVar;
} else {
return;
}
} catch (Throwable th) {
cVar.index = null;
2021-11-08 18:25:28 +00:00
h0.b.a.f.a.i(th);
2021-06-27 20:44:35 +00:00
cVar.unsubscribe();
if (!(obj instanceof e.c) && !e.c(obj)) {
subscriber.onError(OnErrorThrowable.a(th, e.b(obj)));
return;
}
return;
}
}
if (j2 != 0) {
cVar.index = dVar2;
if (j != RecyclerView.FOREVER_NS) {
2021-06-27 20:44:35 +00:00
cVar.b(j2);
}
}
synchronized (cVar) {
if (!cVar.missed) {
cVar.emitting = false;
return;
}
cVar.missed = false;
}
} else {
return;
}
}
}
2021-11-08 18:25:28 +00:00
@Override // j0.l.a.j1.e
2021-06-27 20:44:35 +00:00
public final void i(Throwable th) {
e.c cVar = new e.c(th);
long j = this.index + 1;
this.index = j;
d dVar = new d(cVar, j);
this.tail.set(dVar);
this.tail = dVar;
this.size++;
}
}
/* compiled from: OperatorReplay */
public static final class c<T> extends AtomicLong implements Producer, Subscription {
private static final long serialVersionUID = -4453897557930727610L;
public Subscriber<? super T> child;
public boolean emitting;
public Object index;
public boolean missed;
public final f<T> parent;
public final AtomicLong totalRequested = new AtomicLong();
public c(f<T> fVar, Subscriber<? super T> subscriber) {
this.parent = fVar;
this.child = subscriber;
}
public void a(long j) {
long j2;
long j3;
do {
j2 = this.totalRequested.get();
j3 = j2 + j;
if (j3 < 0) {
j3 = RecyclerView.FOREVER_NS;
2021-06-27 20:44:35 +00:00
}
} while (!this.totalRequested.compareAndSet(j2, j3));
}
public long b(long j) {
long j2;
long j3;
if (j > 0) {
do {
j2 = get();
if (j2 == Long.MIN_VALUE) {
return Long.MIN_VALUE;
}
j3 = j2 - j;
if (j3 < 0) {
2021-11-08 18:25:28 +00:00
StringBuilder sb = new StringBuilder();
sb.append("More produced (");
sb.append(j);
sb.append(") than requested (");
throw new IllegalStateException(c.d.b.a.a.B(sb, j2, ")"));
2021-06-27 20:44:35 +00:00
}
} while (!compareAndSet(j2, j3));
return j3;
}
throw new IllegalArgumentException("Cant produce zero or less");
}
@Override // rx.Subscription
public boolean isUnsubscribed() {
return get() == Long.MIN_VALUE;
}
@Override // rx.Producer
public void j(long j) {
long j2;
long j3;
int i = (j > 0 ? 1 : (j == 0 ? 0 : -1));
if (i >= 0) {
do {
j2 = get();
if (j2 != Long.MIN_VALUE) {
if (j2 < 0 || i != 0) {
j3 = j2 + j;
if (j3 < 0) {
j3 = RecyclerView.FOREVER_NS;
2021-06-27 20:44:35 +00:00
}
} else {
return;
}
} else {
return;
}
} while (!compareAndSet(j2, j3));
a(j);
this.parent.c(this);
this.parent.j.h(this);
}
}
@Override // rx.Subscription
public void unsubscribe() {
if (get() != Long.MIN_VALUE && getAndSet(Long.MIN_VALUE) != Long.MIN_VALUE) {
f<T> fVar = this.parent;
if (!fVar.l) {
synchronized (fVar.m) {
if (!fVar.l) {
2021-11-08 18:25:28 +00:00
j0.l.e.f<c<T>> fVar2 = fVar.m;
2021-06-27 20:44:35 +00:00
c<T>[] cVarArr = fVar2.d;
int i = fVar2.a;
2021-11-08 18:25:28 +00:00
int b = j0.l.e.f.b(hashCode()) & i;
2021-06-27 20:44:35 +00:00
c<T> cVar = cVarArr[b];
boolean z2 = true;
if (cVar != null) {
if (!cVar.equals(this)) {
while (true) {
b = (b + 1) & i;
c<T> cVar2 = cVarArr[b];
if (cVar2 != null) {
if (cVar2.equals(this)) {
fVar2.c(b, cVarArr, i);
break;
}
} else {
break;
}
}
} else {
fVar2.c(b, cVarArr, i);
}
}
if (fVar.m.b != 0) {
z2 = false;
}
if (z2) {
fVar.n = f.i;
}
fVar.o++;
}
}
}
this.parent.c(this);
this.child = null;
}
}
}
/* compiled from: OperatorReplay */
public static final class d extends AtomicReference<d> {
private static final long serialVersionUID = 245354315435971818L;
public final long index;
public final Object value;
public d(Object obj, long j) {
this.value = obj;
this.index = j;
}
}
/* compiled from: OperatorReplay */
public interface e<T> {
void complete();
void g(T t);
void h(c<T> cVar);
void i(Throwable th);
}
/* compiled from: OperatorReplay */
public static final class f<T> extends Subscriber<T> implements Subscription {
public static final c[] i = new c[0];
public final e<T> j;
public boolean k;
public volatile boolean l;
2021-11-08 18:25:28 +00:00
public final j0.l.e.f<c<T>> m = new j0.l.e.f<>();
2021-06-27 20:44:35 +00:00
public c<T>[] n = i;
public volatile long o;
public long p;
public final AtomicBoolean q = new AtomicBoolean();
2021-11-08 18:25:28 +00:00
public boolean r;
2021-06-27 20:44:35 +00:00
2021-11-08 18:25:28 +00:00
/* renamed from: s reason: collision with root package name */
2021-11-30 23:47:08 +00:00
public boolean f2943s;
2021-06-27 20:44:35 +00:00
public long t;
public long u;
public volatile Producer v;
2021-11-08 18:25:28 +00:00
public List<c<T>> w;
2021-06-27 20:44:35 +00:00
/* renamed from: x reason: collision with root package name */
2021-11-30 23:47:08 +00:00
public boolean f2944x;
2021-06-27 20:44:35 +00:00
public f(e<T> eVar) {
this.j = eVar;
request(0);
}
public c<T>[] a() {
c<T>[] cVarArr;
synchronized (this.m) {
c<T>[] cVarArr2 = this.m.d;
int length = cVarArr2.length;
cVarArr = new c[length];
System.arraycopy(cVarArr2, 0, cVarArr, 0, length);
}
return cVarArr;
}
public void b(long j, long j2) {
long j3 = this.u;
Producer producer = this.v;
long j4 = j - j2;
if (j4 != 0) {
this.t = j;
if (producer == null) {
long j5 = j3 + j4;
if (j5 < 0) {
j5 = RecyclerView.FOREVER_NS;
2021-06-27 20:44:35 +00:00
}
this.u = j5;
} else if (j3 != 0) {
this.u = 0;
producer.j(j3 + j4);
} else {
producer.j(j4);
}
} else if (j3 != 0 && producer != null) {
this.u = 0;
producer.j(j3);
}
}
public void c(c<T> cVar) {
long j;
List<c<T>> list;
boolean z2;
long j2;
if (!isUnsubscribed()) {
synchronized (this) {
2021-11-08 18:25:28 +00:00
if (this.r) {
2021-06-27 20:44:35 +00:00
if (cVar != null) {
2021-11-08 18:25:28 +00:00
List list2 = this.w;
2021-06-27 20:44:35 +00:00
if (list2 == null) {
list2 = new ArrayList();
2021-11-08 18:25:28 +00:00
this.w = list2;
2021-06-27 20:44:35 +00:00
}
list2.add(cVar);
} else {
2021-11-30 23:47:08 +00:00
this.f2944x = true;
2021-06-27 20:44:35 +00:00
}
2021-11-30 23:47:08 +00:00
this.f2943s = true;
2021-06-27 20:44:35 +00:00
return;
}
2021-11-08 18:25:28 +00:00
this.r = true;
2021-06-27 20:44:35 +00:00
}
long j3 = this.t;
if (cVar != null) {
j = Math.max(j3, cVar.totalRequested.get());
} else {
c<T>[] a = a();
long j4 = j3;
for (c<T> cVar2 : a) {
if (cVar2 != null) {
j4 = Math.max(j4, cVar2.totalRequested.get());
}
}
j = j4;
}
b(j, j3);
while (!isUnsubscribed()) {
synchronized (this) {
2021-11-30 23:47:08 +00:00
if (!this.f2943s) {
2021-11-08 18:25:28 +00:00
this.r = false;
2021-06-27 20:44:35 +00:00
return;
}
2021-11-30 23:47:08 +00:00
this.f2943s = false;
2021-11-08 18:25:28 +00:00
list = this.w;
this.w = null;
2021-11-30 23:47:08 +00:00
z2 = this.f2944x;
this.f2944x = false;
2021-06-27 20:44:35 +00:00
}
long j5 = this.t;
if (list != null) {
j2 = j5;
for (c<T> cVar3 : list) {
j2 = Math.max(j2, cVar3.totalRequested.get());
}
} else {
j2 = j5;
}
if (z2) {
c<T>[] a2 = a();
for (c<T> cVar4 : a2) {
if (cVar4 != null) {
j2 = Math.max(j2, cVar4.totalRequested.get());
}
}
}
b(j2, j5);
}
}
}
public void d() {
c<T>[] cVarArr = this.n;
if (this.p != this.o) {
synchronized (this.m) {
cVarArr = this.n;
c<T>[] cVarArr2 = this.m.d;
int length = cVarArr2.length;
if (cVarArr.length != length) {
cVarArr = new c[length];
this.n = cVarArr;
}
System.arraycopy(cVarArr2, 0, cVarArr, 0, length);
this.p = this.o;
}
}
e<T> eVar = this.j;
for (c<T> cVar : cVarArr) {
if (cVar != null) {
eVar.h(cVar);
}
}
}
2021-11-08 18:25:28 +00:00
@Override // j0.g
2021-06-27 20:44:35 +00:00
public void onCompleted() {
if (!this.k) {
this.k = true;
try {
this.j.complete();
d();
} finally {
unsubscribe();
}
}
}
2021-11-08 18:25:28 +00:00
@Override // j0.g
2021-06-27 20:44:35 +00:00
public void onError(Throwable th) {
if (!this.k) {
this.k = true;
try {
this.j.i(th);
d();
} finally {
unsubscribe();
}
}
}
2021-11-08 18:25:28 +00:00
@Override // j0.g
2021-06-27 20:44:35 +00:00
public void onNext(T t) {
if (!this.k) {
this.j.g(t);
d();
}
}
@Override // rx.Subscriber
public void setProducer(Producer producer) {
if (this.v == null) {
this.v = producer;
c(null);
d();
return;
}
throw new IllegalStateException("Only a single producer can be set on a Subscriber.");
}
}
/* compiled from: OperatorReplay */
public static final class g<T> extends b<T> {
private static final long serialVersionUID = -5898283885385201806L;
public final int limit;
public g(int i) {
this.limit = i;
}
2021-11-08 18:25:28 +00:00
@Override // j0.l.a.j1.b
2021-06-27 20:44:35 +00:00
public void a() {
if (this.size > this.limit) {
d dVar = get().get();
if (dVar != null) {
this.size--;
set(dVar);
return;
}
throw new IllegalStateException("Empty list!");
}
}
}
/* compiled from: OperatorReplay */
public static final class h<T> extends ArrayList<Object> implements e<T> {
private static final long serialVersionUID = 7063189396499112664L;
public volatile int size;
public h(int i) {
super(i);
}
2021-11-08 18:25:28 +00:00
@Override // j0.l.a.j1.e
2021-06-27 20:44:35 +00:00
public void complete() {
add(e.a);
this.size++;
}
2021-11-08 18:25:28 +00:00
@Override // j0.l.a.j1.e
2021-06-27 20:44:35 +00:00
public void g(T t) {
if (t == null) {
t = (T) e.b;
}
add(t);
this.size++;
}
2021-11-08 18:25:28 +00:00
@Override // j0.l.a.j1.e
2021-06-27 20:44:35 +00:00
public void h(c<T> cVar) {
synchronized (cVar) {
if (cVar.emitting) {
cVar.missed = true;
return;
}
cVar.emitting = true;
}
while (!cVar.isUnsubscribed()) {
int i = this.size;
Integer num = (Integer) cVar.index;
int intValue = num != null ? num.intValue() : 0;
Subscriber<? super T> subscriber = cVar.child;
if (subscriber != null) {
long j = cVar.get();
long j2 = 0;
while (j2 != j && intValue < i) {
Object obj = get(intValue);
try {
if (!e.a(subscriber, obj) && !cVar.isUnsubscribed()) {
intValue++;
j2++;
} else {
return;
}
} catch (Throwable th) {
2021-11-08 18:25:28 +00:00
h0.b.a.f.a.i(th);
2021-06-27 20:44:35 +00:00
cVar.unsubscribe();
if (!(obj instanceof e.c) && !e.c(obj)) {
subscriber.onError(OnErrorThrowable.a(th, e.b(obj)));
return;
}
return;
}
}
if (j2 != 0) {
cVar.index = Integer.valueOf(intValue);
if (j != RecyclerView.FOREVER_NS) {
2021-06-27 20:44:35 +00:00
cVar.b(j2);
}
}
synchronized (cVar) {
if (!cVar.missed) {
cVar.emitting = false;
return;
}
cVar.missed = false;
}
} else {
return;
}
}
}
2021-11-08 18:25:28 +00:00
@Override // j0.l.a.j1.e
2021-06-27 20:44:35 +00:00
public void i(Throwable th) {
add(new e.c(th));
this.size++;
}
}
public j1(Observable.a<T> aVar, Observable<? extends T> observable, AtomicReference<f<T>> atomicReference, Func0<? extends e<T>> func0) {
super(aVar);
this.k = observable;
this.l = atomicReference;
this.m = func0;
}
@Override // rx.Subscription
public boolean isUnsubscribed() {
f<T> fVar = this.l.get();
return fVar == null || fVar.isUnsubscribed();
}
2021-11-08 18:25:28 +00:00
@Override // j0.m.b
2021-10-26 23:51:06 +00:00
public void k0(Action1<? super Subscription> action1) {
2021-06-27 20:44:35 +00:00
f<T> fVar;
while (true) {
fVar = this.l.get();
if (fVar != null && !fVar.isUnsubscribed()) {
break;
}
f<T> fVar2 = new f<>((e) this.m.call());
2021-11-08 18:25:28 +00:00
fVar2.add(new j0.r.a(new m1(fVar2)));
2021-06-27 20:44:35 +00:00
if (this.l.compareAndSet(fVar, fVar2)) {
fVar = fVar2;
break;
}
}
boolean z2 = true;
if (fVar.q.get() || !fVar.q.compareAndSet(false, true)) {
z2 = false;
}
((z) action1).call(fVar);
if (z2) {
2021-10-26 23:51:06 +00:00
this.k.i0(fVar);
2021-06-27 20:44:35 +00:00
}
}
@Override // rx.Subscription
public void unsubscribe() {
this.l.lazySet(null);
}
}