use of com.xinshang.audient.model.entities.SearchResult in project Audient by komamj.
the class SearchPresenter method loadSearchResults.
@Override
public void loadSearchResults(String keyword) {
LogUtils.i(TAG, "loadSearchResults :" + keyword);
mDisposables.clear();
if (isInvalid(keyword)) {
if (mView.isActive()) {
mView.showEmpty(true);
}
return;
}
if (mView != null) {
mView.showProgressBar(true);
}
Disposable disposable = mRepository.getSearchReult(keyword).map(new Function<SearchResult, List<Audient>>() {
@Override
public List<Audient> apply(SearchResult searchResult) throws Exception {
return searchResult.dataBean.audients;
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSubscriber<List<Audient>>() {
@Override
public void onNext(List<Audient> audients) {
if (mView.isActive()) {
mView.showProgressBar(false);
mView.showAudients(audients);
mView.showEmpty(audients.isEmpty());
}
}
@Override
public void onError(Throwable t) {
LogUtils.e(TAG, "loadSearchResults error :" + t.toString());
if (mView.isActive()) {
mView.showProgressBar(false);
mView.showLoadingError();
}
}
@Override
public void onComplete() {
}
});
mDisposables.add(disposable);
}
Aggregations