Skip to content

Instantly share code, notes, and snippets.

@BalakrishnanPT
Last active October 7, 2019 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BalakrishnanPT/af792dc5b4489430c5b28adebefc0a03 to your computer and use it in GitHub Desktop.
Save BalakrishnanPT/af792dc5b4489430c5b28adebefc0a03 to your computer and use it in GitHub Desktop.
private Retrofit getRetrofit() {
if(retrofitInstance != null) return retrofitInstance;
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.level(HttpLoggingInterceptor.Level.BODY);
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.addInterceptor(logging)
.build();
retrofitInstance = new Retrofit.Builder()
.baseUrl(BuildConfig.BASE_URL)
.client(okHttpClient)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofitInstance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment