257 lines
7.9 KiB
Java
257 lines
7.9 KiB
Java
package j0.l.a;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.concurrent.TimeUnit;
|
|
import rx.Observable;
|
|
import rx.Scheduler;
|
|
import rx.Subscriber;
|
|
import rx.functions.Action0;
|
|
import rx.observers.SerializedSubscriber;
|
|
/* compiled from: OperatorBufferWithTime */
|
|
public final class n0<T> implements Observable.b<List<T>, T> {
|
|
public final long i;
|
|
public final long j;
|
|
public final TimeUnit k;
|
|
public final int l;
|
|
public final Scheduler m;
|
|
|
|
/* compiled from: OperatorBufferWithTime */
|
|
public final class a extends Subscriber<T> {
|
|
public final Subscriber<? super List<T>> i;
|
|
public final Scheduler.Worker j;
|
|
public List<T> k = new ArrayList();
|
|
public boolean l;
|
|
|
|
public a(Subscriber<? super List<T>> subscriber, Scheduler.Worker worker) {
|
|
this.i = subscriber;
|
|
this.j = worker;
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onCompleted() {
|
|
try {
|
|
this.j.unsubscribe();
|
|
synchronized (this) {
|
|
if (!this.l) {
|
|
this.l = true;
|
|
List<T> list = this.k;
|
|
this.k = null;
|
|
this.i.onNext(list);
|
|
this.i.onCompleted();
|
|
unsubscribe();
|
|
}
|
|
}
|
|
} catch (Throwable th) {
|
|
Subscriber<? super List<T>> subscriber = this.i;
|
|
c.q.a.k.a.a0(th);
|
|
subscriber.onError(th);
|
|
}
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onError(Throwable th) {
|
|
synchronized (this) {
|
|
if (!this.l) {
|
|
this.l = true;
|
|
this.k = null;
|
|
this.i.onError(th);
|
|
unsubscribe();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onNext(T t) {
|
|
List<T> list;
|
|
synchronized (this) {
|
|
if (!this.l) {
|
|
this.k.add(t);
|
|
if (this.k.size() == n0.this.l) {
|
|
list = this.k;
|
|
this.k = new ArrayList();
|
|
} else {
|
|
list = null;
|
|
}
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
if (list != null) {
|
|
this.i.onNext(list);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* compiled from: OperatorBufferWithTime */
|
|
public final class b extends Subscriber<T> {
|
|
public final Subscriber<? super List<T>> i;
|
|
public final Scheduler.Worker j;
|
|
public final List<List<T>> k = new LinkedList();
|
|
public boolean l;
|
|
|
|
/* compiled from: OperatorBufferWithTime */
|
|
public class a implements Action0 {
|
|
public final /* synthetic */ List i;
|
|
|
|
public a(List list) {
|
|
this.i = list;
|
|
}
|
|
|
|
@Override // rx.functions.Action0
|
|
public void call() {
|
|
boolean z2;
|
|
b bVar = b.this;
|
|
List<T> list = this.i;
|
|
synchronized (bVar) {
|
|
if (!bVar.l) {
|
|
Iterator<List<T>> it = bVar.k.iterator();
|
|
while (true) {
|
|
if (it.hasNext()) {
|
|
if (it.next() == list) {
|
|
it.remove();
|
|
z2 = true;
|
|
break;
|
|
}
|
|
} else {
|
|
z2 = false;
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
if (z2) {
|
|
try {
|
|
bVar.i.onNext(list);
|
|
} catch (Throwable th) {
|
|
c.q.a.k.a.a0(th);
|
|
bVar.onError(th);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public b(Subscriber<? super List<T>> subscriber, Scheduler.Worker worker) {
|
|
this.i = subscriber;
|
|
this.j = worker;
|
|
}
|
|
|
|
public void a() {
|
|
ArrayList arrayList = new ArrayList();
|
|
synchronized (this) {
|
|
if (!this.l) {
|
|
this.k.add(arrayList);
|
|
Scheduler.Worker worker = this.j;
|
|
a aVar = new a(arrayList);
|
|
n0 n0Var = n0.this;
|
|
worker.b(aVar, n0Var.i, n0Var.k);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onCompleted() {
|
|
LinkedList<List> linkedList;
|
|
try {
|
|
synchronized (this) {
|
|
if (!this.l) {
|
|
this.l = true;
|
|
linkedList = new LinkedList(this.k);
|
|
this.k.clear();
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
for (List list : linkedList) {
|
|
this.i.onNext(list);
|
|
}
|
|
this.i.onCompleted();
|
|
unsubscribe();
|
|
} catch (Throwable th) {
|
|
Subscriber<? super List<T>> subscriber = this.i;
|
|
c.q.a.k.a.a0(th);
|
|
subscriber.onError(th);
|
|
}
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onError(Throwable th) {
|
|
synchronized (this) {
|
|
if (!this.l) {
|
|
this.l = true;
|
|
this.k.clear();
|
|
this.i.onError(th);
|
|
unsubscribe();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onNext(T t) {
|
|
LinkedList<List> linkedList;
|
|
synchronized (this) {
|
|
if (!this.l) {
|
|
Iterator<List<T>> it = this.k.iterator();
|
|
linkedList = null;
|
|
while (it.hasNext()) {
|
|
List<T> next = it.next();
|
|
next.add(t);
|
|
if (next.size() == n0.this.l) {
|
|
it.remove();
|
|
if (linkedList == null) {
|
|
linkedList = new LinkedList();
|
|
}
|
|
linkedList.add(next);
|
|
}
|
|
}
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
if (linkedList != null) {
|
|
for (List list : linkedList) {
|
|
this.i.onNext(list);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public n0(long j, long j2, TimeUnit timeUnit, int i, Scheduler scheduler) {
|
|
this.i = j;
|
|
this.j = j2;
|
|
this.k = timeUnit;
|
|
this.l = i;
|
|
this.m = scheduler;
|
|
}
|
|
|
|
@Override // j0.k.b
|
|
public Object call(Object obj) {
|
|
Subscriber subscriber = (Subscriber) obj;
|
|
Scheduler.Worker a2 = this.m.a();
|
|
SerializedSubscriber serializedSubscriber = new SerializedSubscriber(subscriber);
|
|
if (this.i == this.j) {
|
|
a aVar = new a(serializedSubscriber, a2);
|
|
aVar.add(a2);
|
|
subscriber.add(aVar);
|
|
Scheduler.Worker worker = aVar.j;
|
|
m0 m0Var = new m0(aVar);
|
|
long j = this.i;
|
|
worker.c(m0Var, j, j, this.k);
|
|
return aVar;
|
|
}
|
|
b bVar = new b(serializedSubscriber, a2);
|
|
bVar.add(a2);
|
|
subscriber.add(bVar);
|
|
bVar.a();
|
|
Scheduler.Worker worker2 = bVar.j;
|
|
o0 o0Var = new o0(bVar);
|
|
long j2 = this.j;
|
|
worker2.c(o0Var, j2, j2, this.k);
|
|
return bVar;
|
|
}
|
|
}
|