Last active
June 1, 2017 18:34
-
-
Save akbarsha03/dd487d969d8b8e6a77bcecbf9f95e71e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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