Skip to content

Commit

Permalink
Upgrade to OkHttp 4
Browse files Browse the repository at this point in the history
  • Loading branch information
CyborgRahil authored and keyboardsurfer committed Nov 19, 2019
1 parent 332ad29 commit c03db2d
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ buildscript { scriptHandler ->
'material' : '1.1.0-alpha05',
'mockito' : '2.23.0',
'mockito_kotlin' : '2.0.0-RC3',
'okhttp' : '3.10.0',
'okhttp' : '4.0.0',
'retrofit' : '2.6.0',
'room' : '2.1.0',
'supportLibrary' : '28.0.0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ProductHuntModule {
): Retrofit {
return Retrofit.Builder()
.baseUrl(ProductHuntService.ENDPOINT)
.callFactory { okhttpClient.get().newCall(it) }
.callFactory(okhttpClient.get())
.addConverterFactory(deEnvelopingConverter)
.addConverterFactory(converterFactory)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class DesignerNewsDataModule {
): DesignerNewsService {
return Retrofit.Builder()
.baseUrl(DesignerNewsService.ENDPOINT)
.callFactory { client.get().newCall(it) }
.callFactory(client.get())
.addConverterFactory(DeEnvelopingConverter(gson))
.addConverterFactory(DesignerNewsSearchConverter.Factory())
.addConverterFactory(GsonConverterFactory.create(gson))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class DribbbleDataModule {
): DribbbleSearchService =
Retrofit.Builder()
.baseUrl(DribbbleSearchService.ENDPOINT)
.callFactory { client.get().newCall(it) }
.callFactory(client.get())
.addConverterFactory(converterFactory)
.build()
.create(DribbbleSearchService::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ClientAuthInterceptor(
requestBuilder.addHeader("Authorization",
"Bearer ${authTokenDataSource.authToken}")
} else {
val url = chain.request().url().newBuilder()
val url = chain.request().url.newBuilder()
.addQueryParameter("client_id", clientId).build()
requestBuilder.url(url)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ val user = User(
portraitUrl = "www"
)

val errorResponseBody = ResponseBody.create(MediaType.parse(""), "Error")!!
val errorResponseBody = ResponseBody.create(MediaType.parse(""), "Error")

const val userId = 123L

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import okhttp3.MediaType
import okhttp3.ResponseBody
import retrofit2.Response

val errorResponseBody = ResponseBody.create(MediaType.parse(""), "Error")!!
val errorResponseBody = ResponseBody.create(MediaType.parse(""), "Error")

val post1 = GetPostItemResponse(
id = 345L,
Expand All @@ -47,9 +47,9 @@ val post2 = GetPostItemResponse(

val responseDataSuccess = GetPostsResponse(posts = listOf(post1, post2))

val responseSuccess = Response.success(responseDataSuccess)!!
val responseSuccess = Response.success(responseDataSuccess)

val responseError = Response.error<GetPostsResponse>(
400,
errorResponseBody
)!!
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class DataModule {
): DesignerNewsService {
return Retrofit.Builder()
.baseUrl(DesignerNewsService.ENDPOINT)
.callFactory { client.get().newCall(it) }
.callFactory(client.get())
.addConverterFactory(DeEnvelopingConverter(gson))
.addConverterFactory(GsonConverterFactory.create(gson))
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ClientAuthInterceptor(
requestBuilder.addHeader("Authorization",
"Bearer ${authTokenDataSource.authToken}")
} else {
val url = chain.request().url().newBuilder()
val url = chain.request().url.newBuilder()
.addQueryParameter("client_id", clientId).build()
requestBuilder.url(url)
}
Expand Down

0 comments on commit c03db2d

Please sign in to comment.