mirror of
https://github.com/tursom/TursomServer.git
synced 2025-03-14 03:40:06 +08:00
update BlockingCallAdapterFactory
This commit is contained in:
parent
43e9e7ed3e
commit
a1046bca98
@ -4,17 +4,20 @@ import retrofit2.Call
|
||||
import retrofit2.CallAdapter
|
||||
import retrofit2.Retrofit
|
||||
import java.lang.reflect.Type
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
object BlockingCallAdapterFactory : CallAdapter.Factory() {
|
||||
override fun get(
|
||||
returnType: Type,
|
||||
annotations: Array<Annotation>,
|
||||
retrofit: Retrofit
|
||||
): CallAdapter<*, *>? {
|
||||
): CallAdapter<out Any?, out Any?>? {
|
||||
if (getRawType(returnType) == Call::class.java) return null
|
||||
if (getRawType(returnType) == CompletableFuture::class.java) return null
|
||||
if (annotations.any { it is retrofit2.SkipCallbackExecutor }) return null
|
||||
return object : CallAdapter<Any, Any> {
|
||||
return object : CallAdapter<Any?, Any?> {
|
||||
override fun responseType(): Type = returnType
|
||||
override fun adapt(call: Call<Any>): Any? = call.execute().body()
|
||||
override fun adapt(call: Call<Any?>): Any? = call.execute().body()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user