RxJava

作者: ae12 | 来源:发表于2017-05-24 17:48 被阅读8次

    public void login(String name, String pwd,final INetCallback<UserBean> callback) {
    NetWork.getInstance().getNetApi().login(name, pwd)
    .subscribeOn(Schedulers.io())
    .doOnSubscribe (new Action0 () {
    @Override
    public void call () {
    if(callback!=null)
    callback.startRequest();
    App.d("loagin callback not null");
    }
    })
    .subscribeOn (AndroidSchedulers.mainThread ())
    .doOnNext(new Action1<BaseResponse<UserBean>>() {
    @Override
    public void call(BaseResponse<UserBean> userBeanBaseResponse) {
    if(userBeanBaseResponse.isOk()){
    App.d("Login==is ok ok ");
    UserBean user=userBeanBaseResponse.getData();
    UserData.saveUser(user);
    }
    }
    })
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(new BaseSubcriber<BaseResponse<UserBean>>(callback));
    }

    相关文章

      网友评论

          本文标题:RxJava

          本文链接:https://www.haomeiwen.com/subject/ttmwattx.html