184 lines
10 KiB
Java
184 lines
10 KiB
Java
package com.discord.utilities.rx;
|
|
|
|
import android.content.Context;
|
|
import androidx.fragment.app.Fragment;
|
|
import com.discord.app.AppComponent;
|
|
import com.discord.restapi.utils.RetryWithDelay;
|
|
import com.discord.utilities.analytics.Traits;
|
|
import com.discord.utilities.dimmer.DimmerView;
|
|
import com.discord.utilities.error.Error;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerAdapterSimple;
|
|
import d0.z.d.m;
|
|
import j0.l.a.r;
|
|
import j0.l.e.b;
|
|
import j0.p.a;
|
|
import java.lang.ref.WeakReference;
|
|
import java.util.Objects;
|
|
import java.util.concurrent.TimeUnit;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import rx.Observable;
|
|
import rx.Subscription;
|
|
/* compiled from: ObservableExtensions.kt */
|
|
public final class ObservableExtensionsKt {
|
|
public static final <T> void appSubscribe(Observable<T> observable, Context context, String str, Function1<? super Subscription, Unit> function1, Function1<? super T, Unit> function12, Function1<? super Error, Unit> function13, Function0<Unit> function0, Function0<Unit> function02) {
|
|
m.checkNotNullParameter(observable, "$this$appSubscribe");
|
|
m.checkNotNullParameter(str, "errorTag");
|
|
m.checkNotNullParameter(function12, "onNext");
|
|
m.checkNotNullParameter(function0, "onCompleted");
|
|
m.checkNotNullParameter(function02, "onTerminated");
|
|
WeakReference weakReference = new WeakReference(context);
|
|
ObservableExtensionsKt$sam$rx_functions_Action1$0 observableExtensionsKt$sam$rx_functions_Action1$0 = new ObservableExtensionsKt$sam$rx_functions_Action1$0(function12);
|
|
ObservableExtensionsKt$appSubscribe$subscription$1 observableExtensionsKt$appSubscribe$subscription$1 = new ObservableExtensionsKt$appSubscribe$subscription$1(str, function13, weakReference, function02);
|
|
ObservableExtensionsKt$appSubscribe$subscription$2 observableExtensionsKt$appSubscribe$subscription$2 = new ObservableExtensionsKt$appSubscribe$subscription$2(function0, function02);
|
|
Objects.requireNonNull(observable);
|
|
Subscription U = observable.U(new b(observableExtensionsKt$sam$rx_functions_Action1$0, observableExtensionsKt$appSubscribe$subscription$1, observableExtensionsKt$appSubscribe$subscription$2));
|
|
if (function1 != null) {
|
|
m.checkNotNullExpressionValue(U, Traits.Payment.Type.SUBSCRIPTION);
|
|
function1.invoke(U);
|
|
}
|
|
}
|
|
|
|
public static final <T> void appSubscribe(Observable<T> observable, Class<?> cls, Context context, Function1<? super Subscription, Unit> function1, Function1<? super Error, Unit> function12, Function0<Unit> function0, Function0<Unit> function02, Function1<? super T, Unit> function13) {
|
|
m.checkNotNullParameter(observable, "$this$appSubscribe");
|
|
m.checkNotNullParameter(cls, "errorClass");
|
|
m.checkNotNullParameter(function0, "onCompleted");
|
|
m.checkNotNullParameter(function02, "onTerminated");
|
|
m.checkNotNullParameter(function13, "onNext");
|
|
String simpleName = cls.getSimpleName();
|
|
m.checkNotNullExpressionValue(simpleName, "errorClass.simpleName");
|
|
appSubscribe(observable, context, simpleName, function1, function13, function12, function0, function02);
|
|
}
|
|
|
|
public static /* synthetic */ void appSubscribe$default(Observable observable, Context context, String str, Function1 function1, Function1 function12, Function1 function13, Function0 function0, Function0 function02, int i, Object obj) {
|
|
appSubscribe(observable, (i & 1) != 0 ? null : context, str, (i & 4) != 0 ? null : function1, function12, (i & 16) != 0 ? null : function13, (i & 32) != 0 ? ObservableExtensionsKt$appSubscribe$3.INSTANCE : function0, (i & 64) != 0 ? ObservableExtensionsKt$appSubscribe$4.INSTANCE : function02);
|
|
}
|
|
|
|
public static /* synthetic */ void appSubscribe$default(Observable observable, Class cls, Context context, Function1 function1, Function1 function12, Function0 function0, Function0 function02, Function1 function13, int i, Object obj) {
|
|
appSubscribe(observable, cls, (i & 2) != 0 ? null : context, (i & 4) != 0 ? null : function1, (i & 8) != 0 ? null : function12, (i & 16) != 0 ? ObservableExtensionsKt$appSubscribe$1.INSTANCE : function0, (i & 32) != 0 ? ObservableExtensionsKt$appSubscribe$2.INSTANCE : function02, function13);
|
|
}
|
|
|
|
public static final <T> Observable<T> bindToComponentLifecycle(Observable<T> observable, AppComponent appComponent) {
|
|
m.checkNotNullParameter(observable, "$this$bindToComponentLifecycle");
|
|
m.checkNotNullParameter(appComponent, "appComponent");
|
|
Observable<T> a02 = observable.a0(appComponent.getUnsubscribeSignal());
|
|
if (appComponent instanceof Fragment) {
|
|
a02 = a02.x(new ObservableExtensionsKt$bindToComponentLifecycle$$inlined$let$lambda$1(appComponent));
|
|
}
|
|
m.checkNotNullExpressionValue(a02, "takeUntil(appComponent.u…ble\n }\n }");
|
|
return a02;
|
|
}
|
|
|
|
public static final <T> Observable<T> computationBuffered(Observable<T> observable) {
|
|
m.checkNotNullParameter(observable, "$this$computationBuffered");
|
|
Observable<T> I = observable.J().X(a.a()).I(a.a());
|
|
m.checkNotNullExpressionValue(I, "onBackpressureBuffer()\n …Schedulers.computation())");
|
|
return I;
|
|
}
|
|
|
|
public static final <T> Observable<T> computationLatest(Observable<T> observable) {
|
|
m.checkNotNullParameter(observable, "$this$computationLatest");
|
|
Observable<T> I = observable.K().X(a.a()).I(a.a());
|
|
m.checkNotNullExpressionValue(I, "onBackpressureLatest()\n …Schedulers.computation())");
|
|
return I;
|
|
}
|
|
|
|
public static final /* synthetic */ <T> Observable<T> filterIs(Observable<?> observable) {
|
|
m.checkNotNullParameter(observable, "$this$filterIs");
|
|
m.needClassReification();
|
|
Observable<?> x2 = observable.x(ObservableExtensionsKt$filterIs$1.INSTANCE);
|
|
m.needClassReification();
|
|
Observable<T> observable2 = (Observable<T>) x2.F(ObservableExtensionsKt$filterIs$2.INSTANCE);
|
|
m.checkNotNullExpressionValue(observable2, "filter { it is T }.map { it as T }");
|
|
return observable2;
|
|
}
|
|
|
|
public static final /* synthetic */ <T> Observable<T> filterNull(Observable<T> observable) {
|
|
m.checkNotNullParameter(observable, "$this$filterNull");
|
|
Observable<T> observable2 = (Observable<T>) observable.x(ObservableExtensionsKt$filterNull$1.INSTANCE).F(ObservableExtensionsKt$filterNull$2.INSTANCE);
|
|
m.checkNotNullExpressionValue(observable2, "filter { it != null }.map { it!! }");
|
|
return observable2;
|
|
}
|
|
|
|
public static final <T> Observable<T> leadingEdgeThrottle(Observable<T> observable, long j, TimeUnit timeUnit) {
|
|
m.checkNotNullParameter(observable, "$this$leadingEdgeThrottle");
|
|
m.checkNotNullParameter(timeUnit, "timeUnit");
|
|
Observable<T> h02 = Observable.h0(new r(observable.i, new LeadingEdgeThrottle(j, timeUnit)));
|
|
m.checkNotNullExpressionValue(h02, "lift(LeadingEdgeThrottle…indowDuration, timeUnit))");
|
|
return h02;
|
|
}
|
|
|
|
public static final <T> Observable<T> restSubscribeOn(Observable<T> observable, boolean z2) {
|
|
m.checkNotNullParameter(observable, "$this$restSubscribeOn");
|
|
Observable<T> X = observable.X(a.c());
|
|
if (z2) {
|
|
RetryWithDelay retryWithDelay = RetryWithDelay.INSTANCE;
|
|
m.checkNotNullExpressionValue(X, "observable");
|
|
X = RetryWithDelay.restRetry$default(retryWithDelay, X, 0, null, null, 7, null);
|
|
}
|
|
m.checkNotNullExpressionValue(X, "subscribeOn(Schedulers.i… observable\n }\n }");
|
|
return X;
|
|
}
|
|
|
|
public static /* synthetic */ Observable restSubscribeOn$default(Observable observable, boolean z2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
z2 = true;
|
|
}
|
|
return restSubscribeOn(observable, z2);
|
|
}
|
|
|
|
public static final <T> Observable<T> takeSingleUntilTimeout(Observable<T> observable, long j, boolean z2) {
|
|
m.checkNotNullParameter(observable, "$this$takeSingleUntilTimeout");
|
|
Observable<T> Z = observable.Z(1);
|
|
Observable<T> c02 = z2 ? Z.c0(j, TimeUnit.MILLISECONDS) : Z.a0(Observable.d0(j, TimeUnit.MILLISECONDS));
|
|
m.checkNotNullExpressionValue(c02, "take(1).let {\n if (…LISECONDS))\n }\n }");
|
|
return computationLatest(c02);
|
|
}
|
|
|
|
public static /* synthetic */ Observable takeSingleUntilTimeout$default(Observable observable, long j, boolean z2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
j = 5000;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
z2 = true;
|
|
}
|
|
return takeSingleUntilTimeout(observable, j, z2);
|
|
}
|
|
|
|
public static final <T> Observable<T> ui(Observable<T> observable) {
|
|
m.checkNotNullParameter(observable, "$this$ui");
|
|
Observable<T> I = observable.I(j0.j.b.a.a());
|
|
m.checkNotNullExpressionValue(I, "observeOn(AndroidSchedulers.mainThread())");
|
|
return I;
|
|
}
|
|
|
|
public static final <T> Observable<T> ui(Observable<T> observable, AppComponent appComponent, MGRecyclerAdapterSimple<?> mGRecyclerAdapterSimple) {
|
|
m.checkNotNullParameter(observable, "$this$ui");
|
|
m.checkNotNullParameter(appComponent, "appComponent");
|
|
Observable<T> v = bindToComponentLifecycle(ui(observable), appComponent).v(new ObservableExtensionsKt$ui$1(mGRecyclerAdapterSimple));
|
|
m.checkNotNullExpressionValue(v, "ui()\n .bindToComponen…scribeFromUpdates()\n }");
|
|
return v;
|
|
}
|
|
|
|
public static /* synthetic */ Observable ui$default(Observable observable, AppComponent appComponent, MGRecyclerAdapterSimple mGRecyclerAdapterSimple, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
mGRecyclerAdapterSimple = null;
|
|
}
|
|
return ui(observable, appComponent, mGRecyclerAdapterSimple);
|
|
}
|
|
|
|
public static final <T> Observable<T> withDimmer(Observable<T> observable, DimmerView dimmerView, long j) {
|
|
m.checkNotNullParameter(observable, "$this$withDimmer");
|
|
Observable<T> h02 = Observable.h0(new r(observable.i, new OnDelayedEmissionHandler(new ObservableExtensionsKt$withDimmer$1(dimmerView), j, TimeUnit.MILLISECONDS, null, 8, null)));
|
|
m.checkNotNullExpressionValue(h02, "lift(\n OnDelayedE…LISECONDS\n )\n )");
|
|
return h02;
|
|
}
|
|
|
|
public static /* synthetic */ Observable withDimmer$default(Observable observable, DimmerView dimmerView, long j, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
j = 300;
|
|
}
|
|
return withDimmer(observable, dimmerView, j);
|
|
}
|
|
}
|