Skip to content

Commit 8fde9be

Browse files
author
typ0520
committed
move InnerInvocationHandler and PlatformDelegate
1 parent 2c0981c commit 8fde9be

File tree

5 files changed

+37
-49
lines changed

5 files changed

+37
-49
lines changed

app/src/main/java/com/github/typ0520/codee/route/InnerInvocationHandler.java

-30
This file was deleted.

app/src/main/java/retrofit2/PlatformDelegate.java

-18
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.github.typ0520.codee.network.route
2+
3+
import retrofit2.PlatformDelegate
4+
import java.lang.reflect.InvocationHandler
5+
import java.lang.reflect.Method
6+
7+
class InnerInvocationHandler(val routeRetrofit: RouteRetrofit): InvocationHandler {
8+
override fun invoke(proxy: Any, method: Method, vararg args: Any): Any? {
9+
if (method.declaringClass == Object::class.java) {
10+
return method.invoke(proxy, args)
11+
}
12+
if (PlatformDelegate.isDefaultMethod(method)) {
13+
return PlatformDelegate.invokeDefaultMethod(method, method.declaringClass, proxy, args)
14+
}
15+
val realService = routeRetrofit.getRealService(proxy, method, args)
16+
return method.invoke(realService, *args)
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package retrofit2
2+
3+
import java.lang.reflect.Method
4+
5+
/**
6+
* Created by tong on 2018/1/2.
7+
*/
8+
object PlatformDelegate {
9+
private val platform = Platform.get()
10+
11+
fun isDefaultMethod(method: Method): Boolean {
12+
return platform.isDefaultMethod(method)
13+
}
14+
15+
@Throws(Throwable::class)
16+
fun invokeDefaultMethod(method: Method, declaringClass: Class<*>, obj: Any, vararg args: Any): Any? {
17+
return platform.invokeDefaultMethod(method, declaringClass, obj, *args)
18+
}
19+
}

app/src/main/kotlin/com/github/typ0520/codee/network/route/RouteRetrofit.kt

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.github.typ0520.codee.network.route
22

33
import com.github.typ0520.codee.network.Github
4-
import com.github.typ0520.codee.route.InnerInvocationHandler
54
import retrofit2.Retrofit
65
import java.lang.Class
76
import java.lang.reflect.Method

0 commit comments

Comments
 (0)