Skip to content

Commit 8eaff12

Browse files
author
chenhao
committed
增加DEBUG状态
1 parent 0a09d7b commit 8eaff12

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

SmartCode/src/main/java/ch/smart/code/SCConfigModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit
1919
class SCConfigModule : ConfigModule {
2020

2121
override fun applyOptions(context: Context, builder: GlobalConfigModule.Builder) {
22-
if (BuildConfig.DEBUG) {
22+
if (SmartCodeApp.DEBUG) {
2323
builder.formatPrinter(SCPrinter())
2424
} else {
2525
builder.printHttpLogLevel(RequestInterceptor.Level.NONE)

SmartCode/src/main/java/ch/smart/code/SmartCodeApp.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ import java.util.concurrent.TimeUnit
5252

5353
open class SmartCodeApp : Application(), App, IApp, CameraXConfig.Provider {
5454

55+
companion object {
56+
@JvmStatic
57+
var DEBUG: Boolean = false
58+
}
59+
5560
private var appDelegate: AppLifecycles? = null
5661

5762
override fun onCreate() {
@@ -107,7 +112,7 @@ open class SmartCodeApp : Application(), App, IApp, CameraXConfig.Provider {
107112
Utils.init(this)
108113
if (!ProcessUtils.isMainProcess()) return
109114
Timber.plant(Timber.DebugTree())
110-
if (BuildConfig.DEBUG) {
115+
if (SmartCodeApp.DEBUG) {
111116
ARouter.openLog() // 打印日志
112117
ARouter.openDebug() // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
113118
}
@@ -234,7 +239,7 @@ open class SmartCodeApp : Application(), App, IApp, CameraXConfig.Provider {
234239
private fun initRxDownload() {
235240
// 初始化下载器
236241
val downloadConfig = DownloadConfig.Builder.create(this)
237-
.setDebug(BuildConfig.DEBUG)
242+
.setDebug(SmartCodeApp.DEBUG)
238243
.setMaxMission(3)
239244
.enableAutoStart(false) // 自动开始下载
240245
.enableNotification(false) // 启用Notification

SmartCode/src/main/java/ch/smart/code/network/GsonRequestBodyConverter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ch.smart.code.network
22

3-
import ch.smart.code.BuildConfig
3+
import ch.smart.code.SmartCodeApp
44
import com.google.gson.Gson
55
import com.google.gson.TypeAdapter
66
import okhttp3.MediaType
@@ -20,7 +20,7 @@ internal class GsonRequestBodyConverter<T>(
2020

2121
@Throws(IOException::class)
2222
override fun convert(value: T): RequestBody {
23-
if (BuildConfig.DEBUG) {
23+
if (SmartCodeApp.DEBUG) {
2424
Timber.i("Http:%s", gson.toJson(value))
2525
}
2626
val buffer = Buffer()

SmartCode/src/main/java/ch/smart/code/network/GsonResponseBodyConverter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ch.smart.code.network
22

3-
import ch.smart.code.BuildConfig
3+
import ch.smart.code.SmartCodeApp
44
import com.google.gson.Gson
55
import com.google.gson.TypeAdapter
66
import okhttp3.ResponseBody
@@ -23,7 +23,7 @@ internal class GsonResponseBodyConverter<T>(
2323
var responseStr: String? = null
2424
return try {
2525
responseStr = value.string()
26-
if (BuildConfig.DEBUG) {
26+
if (SmartCodeApp.DEBUG) {
2727
Timber.i("Http:%s", responseStr)
2828
}
2929
val json = JSONObject(responseStr)

SmartCode/src/main/java/ch/smart/code/util/CommonFun.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import android.widget.ImageView
1414
import android.widget.TextView
1515
import androidx.annotation.DrawableRes
1616
import androidx.annotation.StringRes
17-
import ch.smart.code.BuildConfig
1817
import ch.smart.code.R
18+
import ch.smart.code.SmartCodeApp
1919
import ch.smart.code.dialog.LoadingDialog
2020
import ch.smart.code.dialog.MsgAlert
2121
import ch.smart.code.view.ContentEditView
@@ -71,7 +71,7 @@ fun exitApp(status: Int = 0) {
7171
fun getOkHttpBuilder(): OkHttpClient.Builder {
7272
val client = ArmsUtils.obtainAppComponentFromContext(Utils.getApp()).okHttpClient()
7373
val builder = OkHttpClient.Builder()
74-
if (!BuildConfig.DEBUG) {
74+
if (!SmartCodeApp.DEBUG) {
7575
builder.proxy(Proxy.NO_PROXY)
7676
}
7777
return builder.dispatcher(client.dispatcher())

0 commit comments

Comments
 (0)