Skip to content

Instantly share code, notes, and snippets.

@vicky7230
Last active August 6, 2018 13:03
Show Gist options
  • Save vicky7230/795b4c8e53121ed34a4e011106e6f022 to your computer and use it in GitHub Desktop.
Save vicky7230/795b4c8e53121ed34a4e011106e6f022 to your computer and use it in GitHub Desktop.
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
if (BuildConfig.DEBUG) {
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
} else {
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.NONE);
}
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(1000, TimeUnit.SECONDS)
.addInterceptor(httpLoggingInterceptor)
.build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Config.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.client(okHttpClient)
.build();
CommonApiService commonApiService = retrofit.create(CommonApiService.class);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment