王学岗csdn网络访问框架的搭建

public abstract class BaseActivity extends FragmentActivity {
private CompositeDisposable disposables = new CompositeDisposable();
public void addDispose(Disposable disposable){
    disposables.add(disposable);
}
@Override
protected void onDestroy() {
    super.onDestroy();
disposables.clear();

}
}

访问网络,使用Retroft

@GET(RunningGroupURL.GET_RUNGROUP_GETRANKFORGROUPUSER)
Observable<PublicResponseEntity<List<RankForGroupUserEntity>>> getRankForGroupUser(@QueryMap HashMap<String, Integer> params);

代码中引用

public class OtherTeamActivity extends BaseActivity {
   
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_other_team);
        addDispose(mServiceApi.getRankForGroupUser(params).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(Comsumer,Consumer));
      }

    }

示例

 addDispose(runningGroupViewMoudle.getRankForGroupUser(groupId, 1, userId, 1, pagesizeOfAve)
//                        .doOnSubscribe(new Consumer<Disposable>() {
//                            @Override
//                            public void accept(Disposable disposable) throws Exception {
//                                AlertDialog.Builder builder=new AlertDialog.Builder(OtherTeamActivity.this);
//                                builder.setMessage("正在加载数据……");
//                                dialog = builder.create();
//                                dialog.show();
//                            }
//                        }).doFinally(new Action() {
//                            @Override
//                            public void run() throws Exception {
//                                dialog.dismiss();
//                            }
//                        })
                        .subscribe(new Consumer<PublicResponseEntity<List<RankForGroupUserEntity>>>() {
                    @Override
                    public void accept(PublicResponseEntity<List<RankForGroupUserEntity>> listPublicResponseEntity) throws Exception {
                        int memberCount = listPublicResponseEntity.getData().get(0).getStepsGroupUserRankResponseList().get(0).getMemberCount();
                        tv_other_team_numbers.setText("团队成员(" + memberCount + ")");
                        List<RankForGroupUserEntity.StepsGroupUserRankResponseListBean> allData = listPublicResponseEntity.getData().get(1).getStepsGroupUserRankResponseList();
                        OtherTeamAverAdapter adapter = new OtherTeamAverAdapter(R.layout.personitemlayout, allData);
                        recyclerView1.setAdapter(adapter);
                        refreshLayout.finishLoadMore();
                        if (pagesizeOfAve >= memberCount) {
                            refreshLayout.setEnableLoadMore(false);
                        }
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {

                    }
                }));
            }
        });
// 跑团个人排名
public Observable<PublicResponseEntity<List<RankForGroupUserEntity>>> getRankForGroupUser(int groupId, int type, int userId, int page, int pageSize){
    HashMap<String, Integer> params = new HashMap<>();
    params.put("groupId",groupId);
    params.put("type",type);
    params.put("userId",userId);
    params.put("page",page);
    params.put("pageSize",pageSize);
    return mServiceApi.getRankForGroupUser(params).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
// 跑团个人排名
@GET(RunningGroupURL.GET_RUNGROUP_GETRANKFORGROUPUSER)
Observable<PublicResponseEntity<List<RankForGroupUserEntity>>> getRankForGroupUser(@QueryMap HashMap<String, Integer> params);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值