Skip to content

Commit

Permalink
[feat/mypage_registered]: Stetho 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
dogdduddy committed Sep 16, 2023
1 parent 7dfc360 commit e68197c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,9 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

// Stetho
implementation 'com.facebook.stetho:stetho:1.6.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.6.0'
implementation 'com.facebook.stetho:stetho-js-rhino:1.6.0'
}
6 changes: 6 additions & 0 deletions app/src/main/java/org/gdsc/jmt/App.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package org.gdsc.jmt

import android.app.Application
import com.facebook.stetho.Stetho
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class App: Application() {

override fun onCreate() {
super.onCreate()

if (BuildConfig.DEBUG) Stetho.initializeWithDefaults(this)
}
}
5 changes: 5 additions & 0 deletions data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@ dependencies {
implementation "androidx.room:room-ktx:2.5.0"
implementation "androidx.room:room-paging:2.5.0"
kapt "androidx.room:room-compiler:2.5.0"

// Stetho
implementation 'com.facebook.stetho:stetho:1.6.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.6.0'
implementation 'com.facebook.stetho:stetho-js-rhino:1.6.0'
}
20 changes: 16 additions & 4 deletions data/src/main/java/org/gdsc/data/di/NetworkModule.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.gdsc.data.di

import android.content.Context
import com.facebook.stetho.okhttp3.StethoInterceptor
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.gdsc.data.BuildConfig
import org.gdsc.data.network.AuthInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
Expand Down Expand Up @@ -53,11 +55,21 @@ class NetworkModule {
private val baseClientBuilder: OkHttpClient.Builder
get() = run {
val clientBuilder = OkHttpClient.Builder()
val loggingInterceptor = HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY

clientBuilder.apply {
if (BuildConfig.DEBUG) {
addInterceptor(HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.HEADERS
})

addInterceptor(HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
})

addNetworkInterceptor(StethoInterceptor())
}
}
return clientBuilder.addInterceptor(loggingInterceptor)
return clientBuilder
}

}
}

0 comments on commit e68197c

Please sign in to comment.