|
8 | 8 | import io.reactivex.observers.DisposableSingleObserver; |
9 | 9 | import io.reactivex.schedulers.Schedulers; |
10 | 10 | import okhttp3.Credentials; |
11 | | -import okhttp3.OkHttpClient; |
12 | | -import okhttp3.logging.HttpLoggingInterceptor; |
13 | | -import retrofit2.Retrofit; |
14 | | -import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; |
15 | | -import retrofit2.converter.gson.GsonConverterFactory; |
16 | 11 |
|
17 | 12 | public class CommunicationController { |
18 | 13 |
|
19 | | - private GithubApi githubApi; |
20 | | - |
21 | 14 | @Inject |
22 | | - public CommunicationController() { |
23 | | - initGithubApi(); |
24 | | - } |
25 | | - |
26 | | - private void initGithubApi() { |
27 | | - HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); |
28 | | - interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); |
29 | | - OkHttpClient okHttpClient = new OkHttpClient.Builder().addInterceptor(interceptor).build(); |
30 | | - Retrofit retrofit = new Retrofit.Builder() |
31 | | - .client(okHttpClient) |
32 | | - .baseUrl(GithubApi.BASE_URL) |
33 | | - .addConverterFactory(GsonConverterFactory.create()) |
34 | | - .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) |
35 | | - .build(); |
| 15 | + GithubApi githubApi; |
36 | 16 |
|
37 | | - githubApi = retrofit.create(GithubApi.class); |
38 | | - } |
| 17 | + @Inject |
| 18 | + public CommunicationController() {} |
39 | 19 |
|
40 | 20 | public void loadIssues(String username, String password, DisposableSingleObserver<List<Issue>> observer, String owner, String repository) { |
41 | 21 | githubApi.getIssues(Credentials.basic(username, password), owner, repository) |
|
0 commit comments