Skip to content

Commit 9a6f567

Browse files
committed
完善路由
1 parent c773222 commit 9a6f567

File tree

9 files changed

+27
-17
lines changed

9 files changed

+27
-17
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
buildscript {
5252
dependencies {
5353
//必须项 👇
54-
classpath 'io.github.FlyJingFish.ModuleCommunication:module-communication-plugin:1.1.7'
54+
classpath 'io.github.FlyJingFish.ModuleCommunication:module-communication-plugin:1.1.8'
5555
}
5656
}
5757
```
@@ -163,7 +163,7 @@ b、如果 ```lib-login``` 也没有引入过 ```communication.export``` 插件
163163
```gradle
164164
dependencies {
165165
//必须项 👇(可以直接放在公共 module)
166-
implementation 'io.github.FlyJingFish.ModuleCommunication:module-communication-annotation:1.1.7'
166+
implementation 'io.github.FlyJingFish.ModuleCommunication:module-communication-annotation:1.1.8'
167167
}
168168
```
169169

@@ -279,9 +279,9 @@ communicationConfig{
279279
```gradle
280280
dependencies {
281281
//使用拦截器(不是必须的)
282-
implementation 'io.github.FlyJingFish.ModuleCommunication:module-communication-intercept:1.1.7'
282+
implementation 'io.github.FlyJingFish.ModuleCommunication:module-communication-intercept:1.1.8'
283283
//使用路径的方式跳转才需要 (不是必须的)
284-
implementation 'io.github.FlyJingFish.ModuleCommunication:module-communication-route:1.1.7'
284+
implementation 'io.github.FlyJingFish.ModuleCommunication:module-communication-route:1.1.8'
285285
}
286286
```
287287

app/src/main/java/com/flyjingfish/modulecommunication/SchemeFilterActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.activity.ComponentActivity
66
import androidx.core.net.toUri
77
import com.flyjingfish.module_communication_annotation.ImplementClassUtils
88
import com.flyjingfish.module_communication_route.ModuleRoute
9+
import com.flyjingfish.user.TestBean
910
import com.flyjingfish.user.UserHelper
1011
import com.google.gson.Gson
1112

@@ -18,8 +19,9 @@ class SchemeFilterActivity : ComponentActivity() {
1819
val user = userHelper?.getUser()
1920
val gson = Gson()
2021
val intArray = intArrayOf(1,2,3)
22+
val testArray = arrayOf(TestBean(1),TestBean(2))
2123
// Log.e("SchemeFilterActivity",gson.toJson(intArray))
22-
val uriTest = "lightrouter://test.flyjingfish.com/user/DetailActivity?age=10&name=hahahaha&aChar=a&user=${gson.toJson(user)}&userIds=${gson.toJson(intArray)}"
24+
val uriTest = "lightrouter://test.flyjingfish.com/user/DetailActivity?age=10&name=hahahaha&aChar=a&user=${gson.toJson(user)}&userIds=${gson.toJson(intArray)}&userList=${gson.toJson(testArray)}"
2325
Log.e("SchemeFilterActivity",uriTest)
2426

2527
val uri = uriTest.toUri()

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ DEVELOPER_ID=FlyJingFish
3535
DEVELOPER_NAME=FlyJingFish
3636
DEVELOPER_EMAIL=[email protected]
3737

38-
TestVersion = 1.1.7
38+
TestVersion = 1.1.8
3939
SonatypeTestCode = 1332
4040
TestType = 0
4141

lib-user/src/main/java/com/flyjingfish/user/DetailActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class DetailActivity extends AppCompatActivity {
2828
@RouteParams(name = "userIds")
2929
private int[] userIds;
3030
@RouteParams(name = "userList")
31-
private ArrayList<User> userList;
31+
private TestBean[] userList;
3232

3333
@Override
3434
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -40,8 +40,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
4040
aChar = getIntent().getCharExtra("aChar",'s');
4141
user = (User) getIntent().getSerializableExtra("user");
4242
userIds = getIntent().getIntArrayExtra("userIds");
43+
userList = (TestBean[]) getIntent().getSerializableExtra("userList");
4344

44-
String logText = "age="+age+",name="+name+",aChar="+aChar+",user="+user+",userIds="+ userIds;
45+
String logText = "age="+age+",name="+name+",aChar="+aChar+",user="+user+",userIds="+ userIds+"userList="+userList;
4546
binding.tvText.setText(logText);
4647
Log.e("DetailActivity",logText);
4748

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.flyjingfish.user
2+
3+
import com.flyjingfish.module_communication_annotation.ExposeBean
4+
import java.io.Serializable
5+
@ExposeBean
6+
data class TestBean(val test:Int): Serializable

module-communication-ksp/src/main/java/com/flyjingfish/module_communication_ksp/RouteParamsConfig.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,17 @@ data class RouteParamsConfig(val className:String,val realClassName :String, val
3333
val typeArguments = element.typeArguments
3434
val type = typeArguments[0].type
3535
if (type != null){
36+
val isSubtype = (type.resolve().declaration as KSClassDeclaration).isSubtype("java.io.Serializable")
37+
||(type.resolve().declaration as KSClassDeclaration).isSubtype("android.os.Parcelable")
38+
3639
val subPackageName = type.resolve().declaration.packageName.asString()
3740
val subClazzName = type.resolve().declaration.toString()
3841
val typeClazzName = "$subPackageName.$subClazzName"
3942
val typeName = ClassName.bestGuess(this.realClassName)
40-
if (typeClazzName == "android.os.Parcelable"
41-
||typeClazzName == "kotlin.CharSequence"
42-
||typeClazzName == "kotlin.String"
43-
||typeClazzName == "java.lang.CharSequence"
44-
||typeClazzName == "java.lang.String"){
43+
if (isSubtype){
4544
typeName.parameterizedBy(ClassName.bestGuess(typeClazzName))
4645
}else{
47-
null
46+
throw IllegalArgumentException("$typeClazzName 至少需要实现 java.io.Serializable 或 android.os.Parcelable 这两个接口中的一个")
4847
}
4948
}else{
5049
null

module-communication-plugin/src/main/kotlin/com/flyjingfish/module_communication_plugin/LibVersion.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.flyjingfish.module_communication_plugin
22

33
object LibVersion {
4-
const val version = "1.1.7"
4+
const val version = "1.1.8"
55
const val buildDir = "communication"
66
const val pathName = "java"
77
const val resName = "res"

module-communication-route/src/main/java/com/flyjingfish/module_communication_route/utils/IntentUtils.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ fun <T> Intent.putValue(paramName: String, paramsValue: T) {
8383
intent.putExtra(paramName, paramsValue as Array<out CharSequence>)
8484
} else if (paramsValue.isArrayOf<String>()) {
8585
intent.putExtra(paramName, paramsValue as Array<out String>)
86+
} else if (paramsValue.isArrayOf<Serializable>()) {
87+
intent.putExtra(paramName, paramsValue as Array<out Serializable>)
8688
}
8789
}
8890

version.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#Tue May 21 11:29:17 CST 2024
2-
PROJ_VERSION=1.1.7
1+
#Tue May 21 18:03:24 CST 2024
2+
PROJ_VERSION=1.1.8

0 commit comments

Comments
 (0)