RxJava

public void login(String name, String pwd,final INetCallback 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>() {
@Override
public void call(BaseResponse userBeanBaseResponse) {
if(userBeanBaseResponse.isOk()){
App.d("Login==is ok ok ");
UserBean user=userBeanBaseResponse.getData();
UserData.saveUser(user);
}
}
})
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new BaseSubcriber>(callback));
}

你可能感兴趣的:(RxJava)