feat(deps): 升级 RxJava 至 v3 并更新相关依赖
This commit is contained in:
@@ -54,23 +54,25 @@ dependencies {
|
||||
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
|
||||
api "androidx.appcompat:appcompat:${rootProject.ext.XAppcompatVersion}"
|
||||
api 'com.google.code.gson:gson:2.8.2'
|
||||
api 'io.reactivex:rxandroid:1.2.0'
|
||||
api 'io.reactivex:rxjava:1.1.5'
|
||||
api 'com.google.code.gson:gson:2.8.5'
|
||||
api 'io.reactivex.rxjava3:rxjava:3.0.0'
|
||||
api 'io.reactivex.rxjava3:rxandroid:3.0.0'
|
||||
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.2.0'
|
||||
implementation 'com.github.franmontiel:PersistentCookieJar:v1.0.1'
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
// implementation 'com.squareup.retrofit2:adapter-rxjava:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
implementation 'com.github.franmontiel:PersistentCookieJar:v1.0.1'
|
||||
|
||||
api 'androidx.lifecycle:lifecycle-runtime:2.0.0'
|
||||
api 'androidx.lifecycle:lifecycle-extensions:2.0.0'
|
||||
kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0'
|
||||
api 'androidx.lifecycle:lifecycle-runtime:2.2.0'
|
||||
api 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||
kapt 'androidx.lifecycle:lifecycle-compiler:2.2.0'
|
||||
|
||||
}
|
||||
|
||||
@@ -2,33 +2,35 @@ package com.arialyy.frame.base.net;
|
||||
|
||||
import com.arialyy.frame.util.show.FL;
|
||||
import com.arialyy.frame.util.show.L;
|
||||
import rx.Observable;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.functions.Func1;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableSource;
|
||||
import io.reactivex.rxjava3.core.ObservableTransformer;
|
||||
import io.reactivex.rxjava3.functions.Function;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by “Aria.Lao” on 2016/10/26.
|
||||
* HTTP数据回调
|
||||
*/
|
||||
public abstract class HttpCallback<T> implements INetResponse<T>, Observable.Transformer<T, T> {
|
||||
public abstract class HttpCallback<T> implements INetResponse<T>, ObservableTransformer<T, T> {
|
||||
|
||||
@Override public void onFailure(Throwable e) {
|
||||
L.e("HttpCallback", FL.getExceptionString(e));
|
||||
}
|
||||
|
||||
@Override public Observable<T> call(Observable<T> observable) {
|
||||
@Override public ObservableSource<T> apply(Observable<T> observable) {
|
||||
Observable<T> tObservable = observable.subscribeOn(Schedulers.io())
|
||||
.unsubscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.map(new Func1<T, T>() {
|
||||
@Override public T call(T t) {
|
||||
.map(new Function<T, T>() {
|
||||
@Override public T apply(T t) {
|
||||
onResponse(t);
|
||||
return t;
|
||||
}
|
||||
})
|
||||
.onErrorReturn(new Func1<Throwable, T>() {
|
||||
@Override public T call(Throwable throwable) {
|
||||
.onErrorReturn(new Function<Throwable, T>() {
|
||||
@Override public T apply(Throwable throwable) {
|
||||
onFailure(throwable);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.google.gson.Gson;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
|
||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
/**
|
||||
@@ -79,7 +79,7 @@ public class NetManager {
|
||||
;
|
||||
final Retrofit.Builder builder = new Retrofit.Builder().client(okHttpClient)
|
||||
.baseUrl(NetConstant.BASE_URL)
|
||||
.addCallAdapterFactory(RxJavaCallAdapterFactory.create());
|
||||
.addCallAdapterFactory(RxJava3CallAdapterFactory.create());
|
||||
builder.addConverterFactory(f);
|
||||
return builder.build().create(service);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user