199 lines
5.9 KiB
Java
199 lines
5.9 KiB
Java
package o;
|
|
|
|
import java.util.ArrayDeque;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.Objects;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
/* renamed from: o.fVi, reason: case insensitive filesystem */
|
|
/* loaded from: classes6.dex */
|
|
public final class C13265fVi<T, U extends Collection<? super T>> extends fUX<T, U> {
|
|
private InterfaceC13189fTc<U> a;
|
|
private int b;
|
|
private int e;
|
|
|
|
public C13265fVi(InterfaceC13169fSq<T> interfaceC13169fSq, int i, int i2, InterfaceC13189fTc<U> interfaceC13189fTc) {
|
|
super(interfaceC13169fSq);
|
|
this.e = i;
|
|
this.b = i2;
|
|
this.a = interfaceC13189fTc;
|
|
}
|
|
|
|
@Override // o.AbstractC13163fSk
|
|
public final void subscribeActual(InterfaceC13174fSv<? super U> interfaceC13174fSv) {
|
|
if (this.b == this.e) {
|
|
Sts sts = new Sts(interfaceC13174fSv, this.e, this.a);
|
|
if (sts.c()) {
|
|
this.c.subscribe(sts);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
this.c.subscribe(new LWm(interfaceC13174fSv, this.e, this.b, this.a));
|
|
}
|
|
|
|
/* renamed from: o.fVi$Sts */
|
|
/* loaded from: classes6.dex */
|
|
static final class Sts<T, U extends Collection<? super T>> implements InterfaceC13174fSv<T>, fSJ {
|
|
private U a;
|
|
private int b;
|
|
private InterfaceC13174fSv<? super U> c;
|
|
private InterfaceC13189fTc<U> d;
|
|
private int e;
|
|
private fSJ j;
|
|
|
|
Sts(InterfaceC13174fSv<? super U> interfaceC13174fSv, int i, InterfaceC13189fTc<U> interfaceC13189fTc) {
|
|
this.c = interfaceC13174fSv;
|
|
this.b = i;
|
|
this.d = interfaceC13189fTc;
|
|
}
|
|
|
|
final boolean c() {
|
|
try {
|
|
this.a = (U) Objects.requireNonNull(this.d.d(), "Empty buffer supplied");
|
|
return true;
|
|
} catch (Throwable th) {
|
|
C13147fSI.c(th);
|
|
this.a = null;
|
|
fSJ fsj = this.j;
|
|
if (fsj == null) {
|
|
EnumC13195fTi.a(th, this.c);
|
|
return false;
|
|
}
|
|
fsj.dispose();
|
|
this.c.onError(th);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onSubscribe(fSJ fsj) {
|
|
if (EnumC13192fTf.d(this.j, fsj)) {
|
|
this.j = fsj;
|
|
this.c.onSubscribe(this);
|
|
}
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final void dispose() {
|
|
this.j.dispose();
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final boolean isDisposed() {
|
|
return this.j.isDisposed();
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onNext(T t) {
|
|
U u = this.a;
|
|
if (u != null) {
|
|
u.add(t);
|
|
int i = this.e + 1;
|
|
this.e = i;
|
|
if (i >= this.b) {
|
|
this.c.onNext(u);
|
|
this.e = 0;
|
|
c();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onError(Throwable th) {
|
|
this.a = null;
|
|
this.c.onError(th);
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onComplete() {
|
|
U u = this.a;
|
|
if (u != null) {
|
|
this.a = null;
|
|
if (!u.isEmpty()) {
|
|
this.c.onNext(u);
|
|
}
|
|
this.c.onComplete();
|
|
}
|
|
}
|
|
}
|
|
|
|
/* renamed from: o.fVi$LWm */
|
|
/* loaded from: classes6.dex */
|
|
static final class LWm<T, U extends Collection<? super T>> extends AtomicBoolean implements InterfaceC13174fSv<T>, fSJ {
|
|
private long a;
|
|
private ArrayDeque<U> b = new ArrayDeque<>();
|
|
private InterfaceC13174fSv<? super U> c;
|
|
private int d;
|
|
private InterfaceC13189fTc<U> e;
|
|
private int g;
|
|
private fSJ j;
|
|
|
|
LWm(InterfaceC13174fSv<? super U> interfaceC13174fSv, int i, int i2, InterfaceC13189fTc<U> interfaceC13189fTc) {
|
|
this.c = interfaceC13174fSv;
|
|
this.d = i;
|
|
this.g = i2;
|
|
this.e = interfaceC13189fTc;
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onSubscribe(fSJ fsj) {
|
|
if (EnumC13192fTf.d(this.j, fsj)) {
|
|
this.j = fsj;
|
|
this.c.onSubscribe(this);
|
|
}
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final void dispose() {
|
|
this.j.dispose();
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final boolean isDisposed() {
|
|
return this.j.isDisposed();
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onNext(T t) {
|
|
long j = this.a;
|
|
this.a = 1 + j;
|
|
if (j % this.g == 0) {
|
|
try {
|
|
this.b.offer((Collection) fYR.d(this.e.d(), "The bufferSupplier returned a null Collection."));
|
|
} catch (Throwable th) {
|
|
C13147fSI.c(th);
|
|
this.b.clear();
|
|
this.j.dispose();
|
|
this.c.onError(th);
|
|
return;
|
|
}
|
|
}
|
|
Iterator<U> it = this.b.iterator();
|
|
while (it.hasNext()) {
|
|
U next = it.next();
|
|
next.add(t);
|
|
if (this.d <= next.size()) {
|
|
it.remove();
|
|
this.c.onNext(next);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onError(Throwable th) {
|
|
this.b.clear();
|
|
this.c.onError(th);
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onComplete() {
|
|
while (!this.b.isEmpty()) {
|
|
this.c.onNext(this.b.poll());
|
|
}
|
|
this.c.onComplete();
|
|
}
|
|
}
|
|
}
|