use of com.mindorks.framework.mvp.data.network.model.OpenSourceResponse in project android-mvp-architecture by MindorksOpenSource.
the class OpenSourcePresenter method onViewPrepared.
@Override
public void onViewPrepared() {
getMvpView().showLoading();
getCompositeDisposable().add(getDataManager().getOpenSourceApiCall().subscribeOn(getSchedulerProvider().io()).observeOn(getSchedulerProvider().ui()).subscribe(new Consumer<OpenSourceResponse>() {
@Override
public void accept(@NonNull OpenSourceResponse openSourceResponse) throws Exception {
if (openSourceResponse != null && openSourceResponse.getData() != null) {
getMvpView().updateRepo(openSourceResponse.getData());
}
getMvpView().hideLoading();
}
}, new Consumer<Throwable>() {
@Override
public void accept(@NonNull Throwable throwable) throws Exception {
if (!isViewAttached()) {
return;
}
getMvpView().hideLoading();
// handle the error here
if (throwable instanceof ANError) {
ANError anError = (ANError) throwable;
handleApiError(anError);
}
}
}));
}
Aggregations