feat(deps): 升级 RxJava 至 v3 并更新相关依赖

This commit is contained in:
2026-07-26 05:16:47 +08:00
parent c494c06265
commit 3dfeabdf3b
4 changed files with 36 additions and 32 deletions

View File

@@ -54,23 +54,25 @@ dependencies {
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
api "androidx.appcompat:appcompat:${rootProject.ext.XAppcompatVersion}" api "androidx.appcompat:appcompat:${rootProject.ext.XAppcompatVersion}"
api 'com.google.code.gson:gson:2.8.2' api 'com.google.code.gson:gson:2.8.5'
api 'io.reactivex:rxandroid:1.2.0' api 'io.reactivex.rxjava3:rxjava:3.0.0'
api 'io.reactivex:rxjava:1.1.5' 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 '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-runtime:2.2.0'
api 'androidx.lifecycle:lifecycle-extensions:2.0.0' api 'androidx.lifecycle:lifecycle-extensions:2.2.0'
kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0' kapt 'androidx.lifecycle:lifecycle-compiler:2.2.0'
} }

View File

@@ -2,33 +2,35 @@ package com.arialyy.frame.base.net;
import com.arialyy.frame.util.show.FL; import com.arialyy.frame.util.show.FL;
import com.arialyy.frame.util.show.L; import com.arialyy.frame.util.show.L;
import rx.Observable; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import rx.android.schedulers.AndroidSchedulers; import io.reactivex.rxjava3.core.Observable;
import rx.functions.Func1; import io.reactivex.rxjava3.core.ObservableSource;
import rx.schedulers.Schedulers; 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. * Created by “Aria.Lao” on 2016/10/26.
* HTTP数据回调 * 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) { @Override public void onFailure(Throwable e) {
L.e("HttpCallback", FL.getExceptionString(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()) Observable<T> tObservable = observable.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io()) .unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.map(new Func1<T, T>() { .map(new Function<T, T>() {
@Override public T call(T t) { @Override public T apply(T t) {
onResponse(t); onResponse(t);
return t; return t;
} }
}) })
.onErrorReturn(new Func1<Throwable, T>() { .onErrorReturn(new Function<Throwable, T>() {
@Override public T call(Throwable throwable) { @Override public T apply(Throwable throwable) {
onFailure(throwable); onFailure(throwable);
return null; return null;
} }

View File

@@ -12,7 +12,7 @@ import com.google.gson.Gson;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
/** /**
@@ -79,7 +79,7 @@ public class NetManager {
; ;
final Retrofit.Builder builder = new Retrofit.Builder().client(okHttpClient) final Retrofit.Builder builder = new Retrofit.Builder().client(okHttpClient)
.baseUrl(NetConstant.BASE_URL) .baseUrl(NetConstant.BASE_URL)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create()); .addCallAdapterFactory(RxJava3CallAdapterFactory.create());
builder.addConverterFactory(f); builder.addConverterFactory(f);
return builder.build().create(service); return builder.build().create(service);
} }

View File

@@ -76,18 +76,22 @@ android {
dependencies { dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
api 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'androidx.cardview:cardview:1.0.0'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7' debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
implementation 'androidx.cardview:cardview:1.0.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
implementation 'com.google.android.material:material:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.kotlin_version}" implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.kotlin_version}"
api 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.github.bumptech.glide:glide:3.7.0' implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.pddstudio:highlightjs-android:1.5.0' implementation 'com.pddstudio:highlightjs-android:1.5.0'
@@ -111,7 +115,3 @@ dependencies {
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6' debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
} }
repositories {
mavenCentral()
}