Answers for "android kotlin retrofit singleton"

0

android kotlin retrofit singleton

object RetrofitSingleton {

    private const val BASE_URL = "https://ehospital.gov.in/portalws2/api/ebloodbank/v1001001/"
    var okHttpClient: OkHttpClient =OkHttpClient.Builder()
        .readTimeout(60, TimeUnit.SECONDS)
        .connectTimeout(60, TimeUnit.SECONDS)
        .addInterceptor(HttpLoggingInterceptor().setLevel( HttpLoggingInterceptor.Level.BODY))
        .build()

    val instance: API_Citizens by lazy{
        val retrofit = Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .client(okHttpClient)
            .build()

        retrofit.create(API_Citizens::class.java)
    }
}
Posted by: Guest on April-13-2021

Browse Popular Code Answers by Language