pull/32/head
kunfei 5 years ago
parent 627ce6c164
commit 2e40525679
  1. 8
      app/src/main/java/io/legado/app/help/http/EncodeConverter.kt
  2. 2
      app/src/main/java/io/legado/app/help/http/HttpHelper.kt

@ -6,7 +6,7 @@ import retrofit2.Retrofit
import java.lang.reflect.Type
import java.nio.charset.Charset
class EncodeConverter private constructor(private val encode: String? = null) : Converter.Factory() {
class EncodeConverter(private val encode: String? = null) : Converter.Factory() {
override fun responseBodyConverter(
type: Type?,
@ -33,10 +33,4 @@ class EncodeConverter private constructor(private val encode: String? = null) :
}
}
companion object {
fun create(encode: String? = null): EncodeConverter {
return EncodeConverter(encode)
}
}
}

@ -44,7 +44,7 @@ object HttpHelper {
fun getRetrofit(baseUrl: String, encode: String? = null): Retrofit {
return Retrofit.Builder().baseUrl(baseUrl)
//增加返回值为字符串的支持(以实体类返回)
.addConverterFactory(EncodeConverter.create(encode))
.addConverterFactory(EncodeConverter(encode))
//增加返回值为Observable<T>的支持
.addCallAdapterFactory(CoroutinesCallAdapterFactory.create())
.client(client)

Loading…
Cancel
Save