Add Stetho to debug application (#18)

This commit is contained in:
Kirill Kamakin
2021-11-28 16:32:05 +03:00
committed by GitHub
parent a1b81eca64
commit cc2fb77269
3 changed files with 15 additions and 2 deletions

View File

@@ -157,4 +157,9 @@ dependencies {
// https://mvnrepository.com/artifact/com.google.truth/truth
testImplementation "com.google.truth:truth:1.1.3"
// https://github.com/facebook/stetho/releases
def stetho_version = "1.6.0"
implementation "com.facebook.stetho:stetho:$stetho_version"
implementation "com.facebook.stetho:stetho-okhttp3:$stetho_version"
}

View File

@@ -1,6 +1,7 @@
package gq.kirmanak.mealient
import android.app.Application
import com.facebook.stetho.Stetho
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber
@@ -8,7 +9,10 @@ import timber.log.Timber
class App : Application() {
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
Stetho.initializeWithDefaults(this)
}
Timber.v("onCreate() called")
}
}

View File

@@ -1,5 +1,6 @@
package gq.kirmanak.mealient.data.impl
import com.facebook.stetho.okhttp3.StethoInterceptor
import gq.kirmanak.mealient.BuildConfig
import gq.kirmanak.mealient.data.auth.impl.AuthOkHttpInterceptor
import okhttp3.Interceptor
@@ -14,8 +15,11 @@ class OkHttpBuilder @Inject constructor(
fun buildOkHttp(): OkHttpClient {
Timber.v("buildOkHttp() called")
val builder = OkHttpClient.Builder()
if (BuildConfig.DEBUG) builder.addNetworkInterceptor(buildLoggingInterceptor())
builder.addNetworkInterceptor(authOkHttpInterceptor)
if (BuildConfig.DEBUG) {
builder.addNetworkInterceptor(buildLoggingInterceptor())
builder.addNetworkInterceptor(StethoInterceptor())
}
return builder.build()
}