private void (final long delay) {
if (subscribe != null) {
subscribe.unsubscribe();
subscribe = null;
}
subscribe = Observable.timer(delay, TimeUnit.MILLISECONDS)
.flatMap(new Func1<Long, Observable<GetSomeThingResult>>() {
public Observable<GetSomeThingResult> call(Long aLong) {
return Api.getDefaultApi().getSomeThing();
}
})
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(new Subscriber<GetSomeThingResult>() {
public void onCompleted() {
}
public void onError(Throwable e) {
ToastUtils.showCustomBgToast(getString(R.string.no_net_text) + e.toString());
getAllDatas(Constants.AUTO_REFRESH_DURATION);
}
public void onNext(GetSomeThingResult result) {
getAllDatas(Constants.AUTO_REFRESH_DURATION);
}
});
}
近期评论