use of cx.ring.tv.model.TVListViewModel in project ring-client-android by savoirfairelinux.
the class MainPresenter method subscribePresence.
private void subscribePresence() {
if (mAccountService.getCurrentAccount() == null || mTvListViewModels == null || mTvListViewModels.isEmpty()) {
return;
}
String accountId = mAccountService.getCurrentAccount().getAccountID();
for (TVListViewModel tvListViewModel : mTvListViewModels) {
String ringId = tvListViewModel.getCallContact().getPhones().get(0).getNumber().getRawRingId();
Uri uri = new Uri(ringId);
if (uri.isRingId()) {
mPresenceService.subscribeBuddy(accountId, ringId, true);
} else {
Log.i(TAG, "Trying to subscribe to an invalid uri " + ringId);
}
}
}
use of cx.ring.tv.model.TVListViewModel in project ring-client-android by savoirfairelinux.
the class MainPresenter method refreshContact.
private void refreshContact(String buddy) {
for (int i = 0; i < mTvListViewModels.size(); i++) {
TVListViewModel tvListViewModel = mTvListViewModels.get(i);
CallContact callContact = tvListViewModel.getCallContact();
if (callContact.getIds().get(0).equals("ring:" + buddy)) {
TVListViewModel updatedTvListViewModel = new TVListViewModel(callContact, mPresenceService.isBuddyOnline(callContact.getIds().get(0)));
if (!updatedTvListViewModel.equals(tvListViewModel)) {
getView().refreshContact(i, updatedTvListViewModel);
}
}
}
}
use of cx.ring.tv.model.TVListViewModel 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