use of io.reactivex.observers.DisposableSingleObserver in project ring-client-android by savoirfairelinux.
the class MainPresenter method reloadConversations.
public void reloadConversations() {
getView().showLoading(true);
Account currentAccount = mAccountService.getCurrentAccount();
if (currentAccount == null) {
Log.e(TAG, "reloadConversations: Not able to get currentAccount");
return;
}
final Collection<CallContact> contacts = currentAccount.getContacts().values();
// Get all non-ban contact and then get last message and last call to create a smartList entry
mCompositeDisposable.add(io.reactivex.Observable.fromIterable(contacts).filter(callContact -> !callContact.isBanned()).map(this::modelToViewModel).toSortedList().subscribeOn(Schedulers.computation()).observeOn(mMainScheduler).subscribeWith(new DisposableSingleObserver<List<TVListViewModel>>() {
@Override
public void onSuccess(List<TVListViewModel> tvListViewModels) {
MainPresenter.this.mTvListViewModels = tvListViewModels;
getView().showContacts(tvListViewModels);
getView().showLoading(false);
subscribePresence();
}
@Override
public void onError(Throwable throwable) {
Log.e(TAG, throwable.toString());
getView().showLoading(false);
}
}));
}
Aggregations