Skip to content

Instantly share code, notes, and snippets.

@akbarsha03
Last active June 1, 2017 18:34
Show Gist options
  • Save akbarsha03/dd487d969d8b8e6a77bcecbf9f95e71e to your computer and use it in GitHub Desktop.
Save akbarsha03/dd487d969d8b8e6a77bcecbf9f95e71e to your computer and use it in GitHub Desktop.
class Factory {
public static Api create() {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
httpClient.addInterceptor(logging);
}
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(JacksonConverterFactory.create(new ObjectMapper()))
.client(httpClient.build())
.build();
return retrofit.create(Api.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment