Skip to content

Commit 683152c

Browse files
committed
1.移除RxJava和retrofit的rxjava转换器的依赖
2.注解ServiceApi增加属性rxJava
1 parent 3dbae5b commit 683152c

File tree

15 files changed

+72
-49
lines changed

15 files changed

+72
-49
lines changed

annotation/src/main/java/com/catchpig/annotation/ServiceApi.kt

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,34 @@ import kotlin.reflect.KClass
1212
@Retention(AnnotationRetention.RUNTIME)
1313
@Target(AnnotationTarget.CLASS)
1414
annotation class ServiceApi(
15-
/**
16-
* 域名或者IP
17-
*/
18-
val baseUrl: String,
19-
/**
20-
* 接收数据转换器(封装的有基类-@see BaseResponseBodyConverter)
21-
* 也可以不使用基类,直接继承{@see SerializationConverter}
22-
*/
23-
val responseConverter: KClass<out SerializationConverter<*, *>>,
24-
/**
25-
* 连接超时时间(毫秒)
26-
*/
27-
val connectTimeout: Long = 5000,
28-
/**
29-
* 读取超时时间(毫秒)
30-
*/
31-
val readTimeout: Long = 5000,
32-
/**
33-
* 拦截器
34-
*/
35-
val interceptors: Array<KClass<out Interceptor>> = [],
36-
/**
37-
* debug模式的拦截器
38-
*/
39-
val debugInterceptors: Array<KClass<out Interceptor>> = []
15+
/**
16+
* 域名或者IP
17+
*/
18+
val baseUrl: String,
19+
/**
20+
* 接收数据转换器(封装的有基类-@see BaseResponseBodyConverter)
21+
* 也可以不使用基类,直接继承{@see SerializationConverter}
22+
*/
23+
val responseConverter: KClass<out SerializationConverter<*, *>>,
24+
/**
25+
* 连接超时时间(毫秒)
26+
*/
27+
val connectTimeout: Long = 5000,
28+
/**
29+
* 读取超时时间(毫秒)
30+
*/
31+
val readTimeout: Long = 5000,
32+
/**
33+
* 拦截器
34+
*/
35+
val interceptors: Array<KClass<out Interceptor>> = [],
36+
/**
37+
* debug模式的拦截器
38+
*/
39+
val debugInterceptors: Array<KClass<out Interceptor>> = [],
40+
/**
41+
* 是否使用RxJava做转换器
42+
*/
43+
val rxJava: Boolean = false
4044
)
4145

app/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ android {
3737
buildFeatures {
3838
viewBinding = true
3939
}
40+
namespace 'com.catchpig.kmvvm'
4041
}
4142

4243
dependencies {
@@ -54,6 +55,13 @@ dependencies {
5455
kapt project(path: ':compiler')
5556
// implementation "com.gitee.catchpig.kmvvm:mvvm:$kotlin_mvvm"
5657
// kapt "com.gitee.catchpig.kmvvm:compiler:$kotlin_mvvm"
58+
59+
60+
// implementation("com.squareup.retrofit2:adapter-rxjava3:$retrofit2_version")
61+
62+
//rxjava3
63+
implementation "io.reactivex.rxjava3:rxjava:$rxjava_version"
64+
implementation "io.reactivex.rxjava3:rxandroid:$rxandroid_version"
5765
//刷新-头部
5866
implementation "io.github.scwang90:refresh-header-material:$SmartRefreshLayout_version"
5967
//刷新-底部

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:dist="http://schemas.android.com/apk/distribution"
4-
package="com.catchpig.kmvvm">
3+
xmlns:dist="http://schemas.android.com/apk/distribution">
54
<uses-permission android:name="android.permission.INTERNET"/>
65
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
76
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ buildscript {
2828

2929
}
3030
dependencies {
31-
classpath 'com.android.tools.build:gradle:7.1.3'
31+
classpath 'com.android.tools.build:gradle:7.2.0'
3232
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
3333
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
3434
// NOTE: Do not place your application dependencies here; they belong

compiler/src/main/java/com/catchpig/compiler/ServiceApiProcessor.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,13 @@ class ServiceApiProcessor : BaseProcessor() {
118118
}
119119
}
120120
constructorBuilder = constructorBuilder.addStatement(
121-
"serviceMap.put(%S, %T(%S, %L, %L, $interceptorName,$debugInterceptorName))",
121+
"serviceMap.put(%S, %T(%S, %L, %L, $interceptorName,$debugInterceptorName,%L))",
122122
"$packageName.$className",
123123
CLASS_NAME_SERVICE_PARAM,
124124
service.baseUrl,
125125
service.connectTimeout,
126126
service.readTimeout,
127+
service.rxJava
127128
)
128129
}
129130
return constructorBuilder.build()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Fri Sep 10 22:03:05 CST 2021
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

mvvm/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ android {
3030
buildFeatures {
3131
viewBinding = true
3232
}
33+
namespace 'com.catchpig.mvvm'
3334
}
3435

3536
dependencies {
@@ -60,12 +61,12 @@ dependencies {
6061

6162
//retrofit2
6263
api "com.squareup.retrofit2:retrofit:$retrofit2_version"
63-
api("com.squareup.retrofit2:adapter-rxjava3:$retrofit2_version")
6464
api("com.squareup.retrofit2:converter-gson:$retrofit2_version")
65+
compileOnly("com.squareup.retrofit2:adapter-rxjava3:$retrofit2_version")
6566

6667
//rxjava3
67-
api "io.reactivex.rxjava3:rxjava:$rxjava_version"
68-
api "io.reactivex.rxjava3:rxandroid:$rxandroid_version"
68+
compileOnly "io.reactivex.rxjava3:rxjava:$rxjava_version"
69+
compileOnly "io.reactivex.rxjava3:rxandroid:$rxandroid_version"
6970

7071

7172
api "com.github.catch-pig:LoadingView:$loading_version"

mvvm/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.catchpig.mvvm">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32
<!--读写文件权限-->
43
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
54
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

mvvm/src/main/java/com/catchpig/mvvm/apt/interfaces/GlobalCompiler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface GlobalCompiler {
1717
fun getGlobalConfig(): IGlobalConfig
1818

1919
/**
20-
* 发送Rxjava的异常到被注解FlowError修饰的接口实现类
20+
* 发送Rxjava或者Flow的异常到被注解FlowError修饰的接口实现类
2121
* @param any Any
2222
* @param t Throwable
2323
*/

mvvm/src/main/java/com/catchpig/mvvm/entity/ServiceParam.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ data class ServiceParam(
77
val connectTimeout: Long,
88
val readTimeout: Long,
99
val interceptors: MutableList<Interceptor>,
10-
val debugInterceptors: MutableList<Interceptor>
10+
val debugInterceptors: MutableList<Interceptor>,
11+
val rxJava:Boolean
1112
)

0 commit comments

Comments
 (0)