fix: http logging in debug builds not working due to cronet

This commit is contained in:
Bnyro 2024-05-06 00:25:13 +02:00
parent e49f3e4b85
commit 7ac50280fd
2 changed files with 4 additions and 2 deletions

View File

@ -67,7 +67,6 @@ object RetrofitInstance {
private fun buildClient(): OkHttpClient { private fun buildClient(): OkHttpClient {
val httpClient = OkHttpClient().newBuilder() val httpClient = OkHttpClient().newBuilder()
.addInterceptor(CronetInterceptor.newBuilder(CronetHelper.cronetEngine).build())
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
val loggingInterceptor = HttpLoggingInterceptor().apply { val loggingInterceptor = HttpLoggingInterceptor().apply {
@ -77,6 +76,8 @@ object RetrofitInstance {
httpClient.addInterceptor(loggingInterceptor) httpClient.addInterceptor(loggingInterceptor)
} }
httpClient.addInterceptor(CronetInterceptor.newBuilder(CronetHelper.cronetEngine).build())
return httpClient.build() return httpClient.build()
} }
} }

View File

@ -37,7 +37,6 @@ object ImageHelper {
val maxCacheSize = PreferenceHelper.getString(PreferenceKeys.MAX_IMAGE_CACHE, "128") val maxCacheSize = PreferenceHelper.getString(PreferenceKeys.MAX_IMAGE_CACHE, "128")
val httpClient = OkHttpClient().newBuilder() val httpClient = OkHttpClient().newBuilder()
.addInterceptor(CronetInterceptor.newBuilder(CronetHelper.cronetEngine).build())
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
val loggingInterceptor = HttpLoggingInterceptor().apply { val loggingInterceptor = HttpLoggingInterceptor().apply {
@ -47,6 +46,8 @@ object ImageHelper {
httpClient.addInterceptor(loggingInterceptor) httpClient.addInterceptor(loggingInterceptor)
} }
httpClient.addInterceptor(CronetInterceptor.newBuilder(CronetHelper.cronetEngine).build())
imageLoader = ImageLoader.Builder(context) imageLoader = ImageLoader.Builder(context)
.callFactory(CronetHelper.callFactory) .callFactory(CronetHelper.callFactory)
.crossfade(true) .crossfade(true)