Created
January 13, 2017 23:13
-
-
Save wisnukurniawan/a71e47549443c3a4fa41fb929d6ceefa to your computer and use it in GitHub Desktop.
Retrofit2
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
/** | |
* Created by wisnu on 12/01/2017. | |
*/ | |
public class ClientApi { | |
public static final String API_BASE_URL = "https://api.github.com"; | |
private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); | |
private static Retrofit.Builder builder = | |
new Retrofit.Builder() | |
.baseUrl(API_BASE_URL) | |
.addConverterFactory(GsonConverterFactory.create()); | |
public static <S> S createService(Class<S> serviceClass) { | |
Retrofit retrofit = builder.client(httpClient.build()).build(); | |
return retrofit.create(serviceClass); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment