2021-06-27 20:44:35 +00:00
|
|
|
package rx;
|
|
|
|
|
2021-08-09 22:50:01 +00:00
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
2021-12-21 23:37:30 +00:00
|
|
|
import b.d.b.a.a;
|
2021-11-08 18:25:28 +00:00
|
|
|
import j0.g;
|
2021-06-27 20:44:35 +00:00
|
|
|
import rx.internal.util.SubscriptionList;
|
2022-03-02 20:59:20 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-06-27 20:44:35 +00:00
|
|
|
public abstract class Subscriber<T> implements g<T>, Subscription {
|
|
|
|
private static final long NOT_SET = Long.MIN_VALUE;
|
|
|
|
private Producer producer;
|
|
|
|
private long requested;
|
|
|
|
private final Subscriber<?> subscriber;
|
|
|
|
private final SubscriptionList subscriptions;
|
|
|
|
|
|
|
|
public Subscriber() {
|
|
|
|
this(null, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Subscriber(Subscriber<?> subscriber) {
|
|
|
|
this(subscriber, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Subscriber(Subscriber<?> subscriber, boolean z2) {
|
|
|
|
this.requested = Long.MIN_VALUE;
|
|
|
|
this.subscriber = subscriber;
|
|
|
|
this.subscriptions = (!z2 || subscriber == null) ? new SubscriptionList() : subscriber.subscriptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addToRequested(long j) {
|
|
|
|
long j2 = this.requested;
|
|
|
|
if (j2 == Long.MIN_VALUE) {
|
|
|
|
this.requested = j;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
long j3 = j2 + j;
|
|
|
|
if (j3 < 0) {
|
2021-08-09 22:50:01 +00:00
|
|
|
this.requested = RecyclerView.FOREVER_NS;
|
2021-06-27 20:44:35 +00:00
|
|
|
} else {
|
|
|
|
this.requested = j3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void add(Subscription subscription) {
|
|
|
|
this.subscriptions.a(subscription);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // rx.Subscription
|
|
|
|
public final boolean isUnsubscribed() {
|
2021-12-17 22:03:14 +00:00
|
|
|
return this.subscriptions.k;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onStart() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void request(long j) {
|
|
|
|
if (j >= 0) {
|
|
|
|
synchronized (this) {
|
|
|
|
Producer producer = this.producer;
|
|
|
|
if (producer != null) {
|
|
|
|
producer.j(j);
|
|
|
|
} else {
|
|
|
|
addToRequested(j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2021-11-08 18:25:28 +00:00
|
|
|
throw new IllegalArgumentException(a.s("number requested cannot be negative: ", j));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setProducer(Producer producer) {
|
|
|
|
long j;
|
|
|
|
Subscriber<?> subscriber;
|
|
|
|
boolean z2;
|
|
|
|
synchronized (this) {
|
|
|
|
j = this.requested;
|
|
|
|
this.producer = producer;
|
|
|
|
subscriber = this.subscriber;
|
|
|
|
z2 = subscriber != null && j == Long.MIN_VALUE;
|
|
|
|
}
|
|
|
|
if (z2) {
|
|
|
|
subscriber.setProducer(producer);
|
|
|
|
} else if (j == Long.MIN_VALUE) {
|
2021-08-09 22:50:01 +00:00
|
|
|
producer.j(RecyclerView.FOREVER_NS);
|
2021-06-27 20:44:35 +00:00
|
|
|
} else {
|
|
|
|
producer.j(j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // rx.Subscription
|
|
|
|
public final void unsubscribe() {
|
|
|
|
this.subscriptions.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|