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));
}
网友评论