啦啦


public interface RetrofitService {
    @GET("article/list/0/json")
    //Call<RecyBean> getItem();
    Observable<RecyBean> getMessage();
}
 private void initRecy() {
        Retrofit retrofit = new Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .baseUrl("http://www.wanandroid.com/")
                .build();
        RetrofitService retrofitService = retrofit.create(RetrofitService.class);
        retrofitService.getMessage()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<RecyBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(RecyBean recyBean) {
                        List<RecyBean.DataBean.DatasBean> list = new ArrayList<>();
                        list.addAll(recyBean.getData().getDatas());
                        //List<RecyBean.DataBean.DatasBean> datas = recyBean.getData().getDatas();
                        recy.setLayoutManager(new LinearLayoutManager(MainActivity.this));
                        recy.setAdapter(new RecyAdapter(MainActivity.this,list));
                    }
                });
               }
  /*gson解析*/
    implementation 'com.google.code.gson:gson:2.2.4'
    /*fresco图片处理*/
    implementation 'com.facebook.fresco:fresco:1.11.0'
    /*okhttp网络请求*/
    implementation 'com.squareup.okhttp3:okhttp:3.12.0'
    /*recyclerview展示*/
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    //图片glide
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    /*轮播图 依赖*/
    implementation 'com.youth.banner:banner:1.4.9'
    /*retrofit网络请求*/
    implementation 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
    implementation 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'
    /*RxAndroid所依赖的库*/
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    implementation 'io.reactivex:rxandroid:1.2.1'
    implementation 'io.reactivex:rxjava:1.1.6'
发布了57 篇原创文章 · 获赞 12 · 访问量 8353
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览