Skip to content

Commit 8940022

Browse files
committed
完善代码
1 parent 93fdc93 commit 8940022

File tree

7 files changed

+19
-20
lines changed

7 files changed

+19
-20
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package com.flyjingfish.modulecommunication
22

3-
import android.content.Context
43
import android.content.Intent
54
import android.os.Bundle
65
import android.util.Log
76
import androidx.activity.ComponentActivity
87
import com.flyjingfish.login.LoginActivity
98
import com.flyjingfish.module_communication_intercept.RouterInterceptManager
10-
import com.flyjingfish.module_communication_intercept.intercept.Proceed
9+
import com.flyjingfish.module_communication_intercept.intercept.InterceptPoint
1110
import com.flyjingfish.module_communication_intercept.intercept.RouterIntercept
1211
import com.flyjingfish.modulecommunication.databinding.ActivityMainBinding
1312
import com.flyjingfish.user.UserActivity
@@ -29,7 +28,7 @@ class MainActivity : ComponentActivity() {
2928

3029
binding.btnGoUri.setOnClickListener {
3130
RouterInterceptManager.addIntercept(object :RouterIntercept{
32-
override fun onIntercept(proceed: Proceed) {
31+
override fun onIntercept(proceed: InterceptPoint) {
3332
Log.e("onIntercept","--MainActivity--${proceed.path},params = ${proceed.paramsMap},byPath = ${proceed.byPath}")
3433
proceed.proceed()
3534
}

lib-login/src/main/java/com/flyjingfish/login/LoginIntercept.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.flyjingfish.login
22

33
import android.util.Log
4-
import com.flyjingfish.module_communication_intercept.intercept.Proceed
4+
import com.flyjingfish.module_communication_intercept.intercept.InterceptPoint
55
import com.flyjingfish.module_communication_intercept.intercept.RouterIntercept
66

77
class LoginIntercept : RouterIntercept {
8-
override fun onIntercept(proceed: Proceed) {
8+
override fun onIntercept(proceed: InterceptPoint) {
99
Log.e("onIntercept","--LoginIntercept--${proceed.path},params = ${proceed.paramsMap},byPath = ${proceed.byPath}")
1010
proceed.proceed()
1111
}

lib-user/src/main/java/com/flyjingfish/user/UserIntercept.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.flyjingfish.user
22

33
import android.util.Log
4-
import com.flyjingfish.module_communication_intercept.intercept.Proceed
4+
import com.flyjingfish.module_communication_intercept.intercept.InterceptPoint
55
import com.flyjingfish.module_communication_intercept.intercept.RouterIntercept
66

77
class UserIntercept : RouterIntercept {
8-
override fun onIntercept(proceed: Proceed) {
8+
override fun onIntercept(proceed: InterceptPoint) {
99
Log.e("onIntercept","--UserIntercept--${proceed.path},params = ${proceed.paramsMap},byPath = ${proceed.byPath}")
1010
proceed.proceed()
1111
}

module-communication-intercept/src/main/java/com/flyjingfish/module_communication_intercept/RouterInterceptManager.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.flyjingfish.module_communication_intercept
22

3-
import com.flyjingfish.module_communication_intercept.intercept.Proceed
3+
import com.flyjingfish.module_communication_intercept.intercept.InterceptPoint
44
import com.flyjingfish.module_communication_intercept.intercept.RouterIntercept
55

66
object RouterInterceptManager {
@@ -31,29 +31,29 @@ object RouterInterceptManager {
3131
RouterInterceptManager.intercepts.addAll(intercepts.sortedBy { it.order() })
3232
}
3333

34-
internal fun notifyIntercept(proceed : Proceed) {
34+
internal fun notifyIntercept(point : InterceptPoint) {
3535
if (intercepts.isEmpty()) {
36-
proceed.proceed()
36+
point.proceed()
3737
return
3838
}
3939
val thisIntercepts = mutableSetOf<RouterIntercept>().apply {
4040
addAll(intercepts)
4141
}
4242
val iterator = thisIntercepts.iterator()
43-
proceed.listener = object : Proceed.OnProceedListener {
43+
point.listener = object : InterceptPoint.OnProceedListener {
4444
override fun onInvoke() {
4545
if (iterator.hasNext()) {
4646
val intercept = iterator.next()
4747
iterator.remove()
48-
proceed.hasNext = iterator.hasNext()
49-
intercept.onIntercept(proceed)
48+
point.hasNext = iterator.hasNext()
49+
intercept.onIntercept(point)
5050
}
5151
}
5252
}
5353

54-
proceed.hasNext = thisIntercepts.size > 1
54+
point.hasNext = thisIntercepts.size > 1
5555
val intercept = iterator.next()
5656
iterator.remove()
57-
intercept.onIntercept(proceed)
57+
intercept.onIntercept(point)
5858
}
5959
}

module-communication-intercept/src/main/java/com/flyjingfish/module_communication_intercept/cut/RouteInterceptCut.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import com.flyjingfish.android_aop_annotation.anno.AndroidAopMatchClassMethod
66
import com.flyjingfish.android_aop_annotation.base.MatchClassMethod
77
import com.flyjingfish.android_aop_annotation.enums.MatchType
88
import com.flyjingfish.module_communication_annotation.bean.PathInfo
9-
import com.flyjingfish.module_communication_intercept.intercept.Proceed
9+
import com.flyjingfish.module_communication_intercept.intercept.InterceptPoint
1010
import com.flyjingfish.module_communication_intercept.RouterInterceptManager
1111

1212
@AndroidAopMatchClassMethod(
@@ -21,8 +21,8 @@ internal class RouteInterceptCut : MatchClassMethod{
2121
val byPath = joinPoint.args?.get(2)
2222
val pathInfo = joinPoint.args?.get(3)
2323
val intent = joinPoint.args?.get(4)
24-
val proceed = Proceed(joinPoint,path as String,map as MutableMap<String,Any?>,pathInfo as PathInfo,byPath as Boolean,intent as Intent)
25-
RouterInterceptManager.notifyIntercept(proceed)
24+
val point = InterceptPoint(joinPoint,path as String,map as MutableMap<String,Any?>,pathInfo as PathInfo,byPath as Boolean,intent as Intent)
25+
RouterInterceptManager.notifyIntercept(point)
2626
return null
2727
}
2828
}

module-communication-intercept/src/main/java/com/flyjingfish/module_communication_intercept/intercept/Proceed.kt renamed to module-communication-intercept/src/main/java/com/flyjingfish/module_communication_intercept/intercept/InterceptPoint.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.content.Intent
44
import com.flyjingfish.android_aop_annotation.ProceedJoinPoint
55
import com.flyjingfish.module_communication_annotation.bean.PathInfo
66

7-
class Proceed(
7+
class InterceptPoint(
88
private val joinPoint: ProceedJoinPoint,
99
/**
1010
* 路由页面的 path
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.flyjingfish.module_communication_intercept.intercept
22

33
interface RouterIntercept {
4-
fun onIntercept(proceed: Proceed)
4+
fun onIntercept(point: InterceptPoint)
55
fun order():Int
66
}

0 commit comments

Comments
 (0)