From af992fd7f5730d0f164bab4c3f578d08ade2243c Mon Sep 17 00:00:00 2001 From: yimiao Date: Fri, 25 Feb 2022 11:03:43 +0800 Subject: [PATCH] =?UTF-8?q?[desc]:=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=8B=A6=E6=88=AA=E5=99=A8=20[author]:Alex=20Wang?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commonlib/net/manager/RequestManager.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/commonLib/src/main/java/com/common/commonlib/net/manager/RequestManager.kt b/commonLib/src/main/java/com/common/commonlib/net/manager/RequestManager.kt index 2a274bb..0381abd 100644 --- a/commonLib/src/main/java/com/common/commonlib/net/manager/RequestManager.kt +++ b/commonLib/src/main/java/com/common/commonlib/net/manager/RequestManager.kt @@ -43,9 +43,7 @@ object RequestManager { * 创建service */ fun create(service: Class): T { -// if (mRetrofit == null) { - init(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())