Search in sources :

Example 1 with TVListViewModel

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);
        }
    }
}
Also used : TVListViewModel(cx.ring.tv.model.TVListViewModel) Uri(cx.ring.model.Uri)

Example 2 with TVListViewModel

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);
            }
        }
    }
}
Also used : TVListViewModel(cx.ring.tv.model.TVListViewModel) CallContact(cx.ring.model.CallContact)

Example 3 with TVListViewModel

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);
        }
    }));
}
Also used : Account(cx.ring.model.Account) TVListViewModel(cx.ring.tv.model.TVListViewModel) DisposableSingleObserver(io.reactivex.observers.DisposableSingleObserver) ArrayList(java.util.ArrayList) List(java.util.List) CallContact(cx.ring.model.CallContact)

Aggregations

TVListViewModel (cx.ring.tv.model.TVListViewModel)3 CallContact (cx.ring.model.CallContact)2 Account (cx.ring.model.Account)1 Uri (cx.ring.model.Uri)1 DisposableSingleObserver (io.reactivex.observers.DisposableSingleObserver)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1