|
|
|
@ -43,9 +43,7 @@ object RequestManager {
|
|
|
|
|
* 创建service
|
|
|
|
|
*/
|
|
|
|
|
fun <T> create(service: Class<T>): T {
|
|
|
|
|
// if (mRetrofit == null) {
|
|
|
|
|
init(null)
|
|
|
|
|
// }
|
|
|
|
|
return mRetrofit!!.create(service)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -64,9 +62,6 @@ object RequestManager {
|
|
|
|
|
|
|
|
|
|
// 动态HOST替换拦截器
|
|
|
|
|
builder.addInterceptor(HostInterceptor())
|
|
|
|
|
// 添加日志拦截器
|
|
|
|
|
loggingInterceptor.level = logLevel
|
|
|
|
|
builder.addInterceptor(loggingInterceptor)
|
|
|
|
|
// 添加通用拦截器
|
|
|
|
|
val interceptorList = CommonInterceptorManager.getInterceptorsByRequiredTypeList()
|
|
|
|
|
if (interceptorList.isNotEmpty()) {
|
|
|
|
@ -80,6 +75,10 @@ object RequestManager {
|
|
|
|
|
for (intercept in interceptors!!) {
|
|
|
|
|
builder.addInterceptor(intercept)
|
|
|
|
|
}
|
|
|
|
|
// 添加日志拦截器
|
|
|
|
|
loggingInterceptor.level = logLevel
|
|
|
|
|
builder.addInterceptor(loggingInterceptor)
|
|
|
|
|
|
|
|
|
|
mRetrofitWithIntercept = Retrofit.Builder()
|
|
|
|
|
.client(builder.build())
|
|
|
|
|
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
|
|
|
@ -87,6 +86,10 @@ object RequestManager {
|
|
|
|
|
.baseUrl("https://www")
|
|
|
|
|
.build()
|
|
|
|
|
} else {
|
|
|
|
|
// 添加日志拦截器
|
|
|
|
|
loggingInterceptor.level = logLevel
|
|
|
|
|
builder.addInterceptor(loggingInterceptor)
|
|
|
|
|
|
|
|
|
|
mRetrofit = Retrofit.Builder()
|
|
|
|
|
.client(builder.build())
|
|
|
|
|
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
|
|
|
|