Commit f4ac32ac authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update OkHttpHelper.kt

parent a8ca84b6
...@@ -9,6 +9,13 @@ import okhttp3.OkHttpClient ...@@ -9,6 +9,13 @@ import okhttp3.OkHttpClient
object OkHttpHelper { object OkHttpHelper {
fun getClient(): OkHttpClient {
if (httpClient == null) {
httpClient = OkHttpClient()
}
return httpClient ?: throw AssertionError("httpClient set to null by another thread")
}
fun getClientForUploadFile(): OkHttpClient { fun getClientForUploadFile(): OkHttpClient {
if (httpClientForUploadFile == null) { if (httpClientForUploadFile == null) {
httpClientForUploadFile = OkHttpClient.Builder().build() httpClientForUploadFile = OkHttpClient.Builder().build()
...@@ -37,7 +44,8 @@ object OkHttpHelper { ...@@ -37,7 +44,8 @@ object OkHttpHelper {
return httpClientForWS ?: throw AssertionError("httpClientForWS set to null by another thread") return httpClientForWS ?: throw AssertionError("httpClientForWS set to null by another thread")
} }
private var httpClient: OkHttpClient? = null
private var httpClientForUploadFile: OkHttpClient? = null private var httpClientForUploadFile: OkHttpClient? = null
private var httpClientForDownloadFile: OkHttpClient? = null private var httpClientForDownloadFile: OkHttpClient? = null
private var httpClientForWS: OkHttpClient? = null private var httpClientForWS: OkHttpClient? = null
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment