Skip to content

Instantly share code, notes, and snippets.

@Danil0v3s
Last active October 16, 2017 20:11
Show Gist options
  • Save Danil0v3s/9b5a4038d75bbb5825c72b97bf6808fd to your computer and use it in GitHub Desktop.
Save Danil0v3s/9b5a4038d75bbb5825c72b97bf6808fd to your computer and use it in GitHub Desktop.
public class AppBaseService {
private static final AppBaseService ourInstance = new AppBaseService();
private static String BASE_URL = "https://en.wikipedia.org/";
private Retrofit retrofit;
private final static OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(2, TimeUnit.MINUTES)
.connectTimeout(2, TimeUnit.MINUTES)
.build();
public static AppBaseService getInstance() {
return ourInstance;
}
private AppBaseService() {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
public WikipediaService getWikiService() {
return retrofit.create(WikipediaService.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment