-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Gaëtan Muller <[email protected]>
- Loading branch information
Showing
8 changed files
with
57 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/network/PillarboxOkHttp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.player.network | ||
|
||
import ch.srgssr.pillarbox.player.BuildConfig | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import okhttp3.logging.HttpLoggingInterceptor.Level | ||
|
||
/** | ||
* Provide a [OkHttpClient] instance tailored for Pillarbox's needs. | ||
*/ | ||
object PillarboxOkHttp { | ||
|
||
private val okHttpClient: OkHttpClient by lazy { | ||
OkHttpClient.Builder() | ||
.addInterceptor( | ||
HttpLoggingInterceptor().apply { | ||
val logLevel = if (BuildConfig.DEBUG) Level.BASIC else Level.NONE | ||
setLevel(logLevel) | ||
} | ||
) | ||
.build() | ||
} | ||
|
||
/** | ||
* Returns the [OkHttpClient] tailored for Pillarbox's needs. | ||
* | ||
* @return A [OkHttpClient] instance. | ||
*/ | ||
operator fun invoke(): OkHttpClient { | ||
return okHttpClient | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters