Skip to content

Commit 4c0e832

Browse files
committed
增加网络请求打印的总开关debug
1 parent b3b0df9 commit 4c0e832

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGE_lOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# CHANGE LOG
2+
### v1.4.1
3+
4+
+ 增加网络请求打印的总开关debug
5+
26
### v1.4.0
37

48
+ 优化Flow的lifecycle回调

mvvm/src/main/java/com/catchpig/mvvm/network/manager/NetManager.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class NetManager private constructor() {
2424

2525
private val serviceMap = hashMapOf<String, Any>()
2626

27+
private var debug: Boolean = false
28+
2729
fun <S : Any> getService(serviceClass: Class<S>, baseUrl: String? = null): S {
2830
val className = serviceClass.name
2931
val service = serviceMap[className]
@@ -46,6 +48,10 @@ class NetManager private constructor() {
4648
}
4749
}
4850

51+
fun setDebug(debug: Boolean) {
52+
this.debug = debug
53+
}
54+
4955
private fun getClient(serviceParam: ServiceParam): OkHttpClient {
5056
var builder = OkHttpClient
5157
.Builder()
@@ -57,7 +63,7 @@ class NetManager private constructor() {
5763
* 读取数据超时时间
5864
*/
5965
.readTimeout(serviceParam.readTimeout, TimeUnit.MILLISECONDS)
60-
if (serviceParam.debug) {
66+
if (debug && serviceParam.debug) {
6167
serviceParam.debugInterceptors.forEach {
6268
builder = builder.addInterceptor(it)
6369
}

0 commit comments

Comments
 (0)