use of cn.foxconn.matthew.myapp.wanandroid.helper.interceptor.CustomInterceptor in project MyApp by MatthewDevelop.
the class ExampleUnitTest method APITest.
@Test
public void APITest() {
String BASE_URL = "http://wanandroid.com/";
OkHttpClient.Builder builder = new OkHttpClient.Builder();
// 添加公共拦截器
builder.addInterceptor(new CustomInterceptor());
Retrofit retrofit = new Retrofit.Builder().client(builder.build()).baseUrl(BASE_URL).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).addConverterFactory(GsonConverterFactory.create()).build();
WanService movieService = retrofit.create(WanService.class);
boolean test = true;
if (test) {
} else {
movieService.getTagData().subscribe(new Observer<ResponseData<List<TypeTagVO>>>() {
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(ResponseData<List<TypeTagVO>> listResponseData) {
System.out.println(listResponseData.toString());
}
});
movieService.getHomeBannerList().subscribe(new Observer<ResponseData<List<BannerBean>>>() {
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onComplete() {
}
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(ResponseData<List<BannerBean>> listResponseData) {
System.out.println(listResponseData.toString());
}
});
movieService.getHomeArticleList(5).subscribe(new Observer<ResponseData<ArticleListVO>>() {
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(ResponseData<ArticleListVO> articleListVOResponseData) {
System.out.println(articleListVOResponseData.toString());
}
});
}
}
Aggregations