Search in sources :

Example 1 with BannerBean

use of cn.foxconn.matthew.myapp.wanandroid.bean.pojo.BannerBean 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());
            }
        });
    }
}
Also used : Disposable(io.reactivex.disposables.Disposable) OkHttpClient(okhttp3.OkHttpClient) ResponseData(cn.foxconn.matthew.myapp.wanandroid.bean.ResponseData) CustomInterceptor(cn.foxconn.matthew.myapp.wanandroid.helper.interceptor.CustomInterceptor) WanService(cn.foxconn.matthew.myapp.wanandroid.api.WanService) Retrofit(retrofit2.Retrofit) ArticleListVO(cn.foxconn.matthew.myapp.wanandroid.bean.pojovo.ArticleListVO) BannerBean(cn.foxconn.matthew.myapp.wanandroid.bean.pojo.BannerBean) TypeTagVO(cn.foxconn.matthew.myapp.wanandroid.bean.pojovo.TypeTagVO) List(java.util.List) Test(org.junit.Test)

Aggregations

WanService (cn.foxconn.matthew.myapp.wanandroid.api.WanService)1 ResponseData (cn.foxconn.matthew.myapp.wanandroid.bean.ResponseData)1 BannerBean (cn.foxconn.matthew.myapp.wanandroid.bean.pojo.BannerBean)1 ArticleListVO (cn.foxconn.matthew.myapp.wanandroid.bean.pojovo.ArticleListVO)1 TypeTagVO (cn.foxconn.matthew.myapp.wanandroid.bean.pojovo.TypeTagVO)1 CustomInterceptor (cn.foxconn.matthew.myapp.wanandroid.helper.interceptor.CustomInterceptor)1 Disposable (io.reactivex.disposables.Disposable)1 List (java.util.List)1 OkHttpClient (okhttp3.OkHttpClient)1 Test (org.junit.Test)1 Retrofit (retrofit2.Retrofit)1