Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alfonsogarsan/1bdacefa8cd43fd50e91cdae73c3ce94 to your computer and use it in GitHub Desktop.
Save alfonsogarsan/1bdacefa8cd43fd50e91cdae73c3ce94 to your computer and use it in GitHub Desktop.
object RetrofitClient {
private val retrofit by lazy {
val okHttpClient = OkHttpClient.Builder()
.build()
Retrofit.Builder()
.baseUrl("https://yesno.wtf/")
.client(okHttpClient)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create(GsonBuilder().create()))
.build()
}
fun <T> getService(klass: Class<T>): T {
return retrofit.create(klass)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment