Advertisement
wetalkas

RestClient

Sep 16th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. public class RestClient {
  2. private static final String VK_BASE_URL = "https://api.vk.com/method/";
  3.  
  4. private Retrofit mRetrofit;
  5.  
  6. public RestClient() {
  7.  
  8. HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
  9. logging.setLevel(HttpLoggingInterceptor.Level.BODY);
  10. OkHttpClient httpClient = new OkHttpClient.Builder().addInterceptor(logging).build();
  11.  
  12.  
  13.  
  14. mRetrofit = new Retrofit.Builder()
  15. .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
  16. .addConverterFactory(GsonConverterFactory.create())
  17. .baseUrl(VK_BASE_URL)
  18. .client(httpClient)
  19. .build();
  20. }
  21.  
  22. public <S> S createService(Class<S> serviceClass) {
  23. return mRetrofit.create(serviceClass);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement