Retrofit


  1. 原网址 https://www.jianshu.com/p/f57b7cdb1c99
  2. 在gradle文件中引用retrofit
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:retrofit-converters:2.3.0'
    compile 'com.squareup.retrofit2:retrofit-adapters:2.3.0'

如果需要使用更多扩展功能,比如gson转换,rxjava适配等,可以视自己需要继续添加引用

    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'


 /// http://120.27.23.105/product/getProducts?pscid=39&page=1
 // @GET("product/getProducts") 是拼接的接口的 参数 ; type类型只能是接口的最后一个参数
//  @QueryMap Map<String, String> map  是要拼接的 请求参数 pscid=39&page=1
  // 注意::Base URL: 以"/"结尾        @Url:不要以"/"开头

.baseUrl("http://120.27.23.105/product/")
@GET("{type}?") Call<BizEntity> getBizInfo(@Path("type") String type, @QueryMap Map<String, String> map)

关闭 接口
@Override
protected void onDestroy() {
    super.onDestroy();
    if (getProducts!=null){
        getProducts.cancel();
        getProducts=null;
    }
}
//     全选与反选
    public void getQuan() {
        priceCount=0;
      if (data!=null){
             Observable.fromArray(data)
                     .flatMap(new Function<List<MyData.DataBean>, ObservableSource<?>>() {
                         @Override
                         public ObservableSource<?> apply(@NonNull List<MyData.DataBean> dataBeen) throws Exception {
                             return Observable.fromIterable(dataBeen);
                         }
                     })
                     .flatMap(new Function<Object, ObservableSource<?>>() {
                          @Override
                          public ObservableSource<?> apply(@NonNull Object o) throws Exception {

                              return Observable.fromIterable(((MyData.DataBean)o).getList());
                          }
                      })
                      .flatMap(new Function<Object, ObservableSource<?>>() {
                          @Override
                          public ObservableSource<?> apply(@NonNull Object o) throws Exception {
                              Map<String, String> map = CommonParamsInterceptor.map;
                              map.clear();
                              String s = quan.isChecked() ? "1" : "0";
                              String pa=quanPath+"&sellerid="+String.valueOf(((MyData.DataBean.ListBean)o).getSellerid())+"&pid="+String.valueOf(((MyData.DataBean.ListBean)o).getPid())+"&selected="+s;
                              return MyRetrofit.getquan(pa);
                          }
                      })
                      .subscribeOn(Schedulers.newThread())
                      .observeOn(AndroidSchedulers.mainThread())
                      .subscribe(new MyObserve(){
                          @Override
                          protected void onMyComplete() {
                              createPresenter().onGeyData(path);
                          }

                          @Override
                          protected void onMyNext(Object o) {

                          }
                      });
      }
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值