use of com.seven.seven.common.network.ApiException in project seven_develop by seven123456.
the class HomePresenter method getHomeBanner.
@Override
public void getHomeBanner() {
/*io.reactivex.Observable observable = HttpObservable.getObservable(apiRetrofit.getHomeNewsInfos());
io.reactivex.Observable observable1 = HttpObservable.getObservable(apiRetrofit.getBannerInfos());
io.reactivex.Observable.mergeDelayError(observable, observable1).retryWhen(new BaseRetryWhen(3, 3000))
.subscribe(new HttpResultObserver<ResponseCustom<Object>>() {
@Override
protected void onLoading(Disposable d) {
}
@Override
protected void onSuccess(ResponseCustom<Object> responseCustom) {
if (getView() != null) {
if (responseCustom.getData() != null) {
count++;
}
if (responseCustom.getData() instanceof HomeNewsInfos) {
EventBus.getDefault().post(new HomeEvents(Constans.HOMEDATA, responseCustom.getData()));
} else if (responseCustom.getData() instanceof List) {
EventBus.getDefault().post(new HomeEvents(Constans.HOMEBANNER, responseCustom.getData()));
}
if (count == 2) {
count = 0;
EventBus.getDefault().post(new HomeEvents(Constans.HOMEDASUCCESS, "成功"));
} */
/*else {
EventBus.getDefault().post(new HomeEvents(Constans.HOMEERROR, "只有一次"));
}*/
/*
}
}
@Override
protected void onFail(ApiException error) {
EventBus.getDefault().post(new HomeEvents(Constans.HOMEERROR, error.getMsg()));
}
});*/
Flowable flowable1 = apiRetrofit.getHomeNewsInfos();
Flowable flowable2 = apiRetrofit.getBannerInfos();
Flowable.concat(flowable1, flowable2).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new HttpResultSubscriber<ResponseCustom<Object>>() {
@Override
protected void onLoading(Disposable d) {
if (getView() != null) {
}
}
@Override
protected void onSuccess(ResponseCustom<Object> responseCustom) {
if (getView() != null) {
if (responseCustom.getData() != null) {
count++;
}
if (responseCustom.getData() instanceof HomeNewsInfos) {
EventBus.getDefault().post(new HomeEvents(Constans.HOMEDATA, responseCustom.getData()));
} else if (responseCustom.getData() instanceof List) {
EventBus.getDefault().post(new HomeEvents(Constans.HOMEBANNER, responseCustom.getData()));
}
if (count == 2) {
count = 0;
EventBus.getDefault().post(new HomeEvents(Constans.HOMEDASUCCESS, "成功"));
}
}
}
@Override
protected void onFail(ApiException e) {
EventBus.getDefault().post(new HomeEvents(Constans.HOMEERROR, e.getMsg()));
}
});
}
use of com.seven.seven.common.network.ApiException in project seven_develop by seven123456.
the class GankHttpObserver method onError.
@Override
public void onError(Throwable e) {
if (e instanceof ApiException || e instanceof UnknownServiceException) {
_onError((ApiException) e);
Log.e("onerror", "错误编码===" + ((ApiException) e).getCode() + "错误信息===" + ((ApiException) e).getMsg());
} else {
this._onError(new ApiException(e, UN_KNOWN_ERROR));
}
// this._onError(e);
}
Aggregations