Skip to content

Instantly share code, notes, and snippets.

@wisnukurniawan
Created January 13, 2017 23:13
Show Gist options
  • Save wisnukurniawan/a71e47549443c3a4fa41fb929d6ceefa to your computer and use it in GitHub Desktop.
Save wisnukurniawan/a71e47549443c3a4fa41fb929d6ceefa to your computer and use it in GitHub Desktop.
Retrofit2
/**
* 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