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