Search in sources :

Example 6 with DisposableSingleObserver

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);
        }
    }));
}
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

DisposableSingleObserver (io.reactivex.observers.DisposableSingleObserver)6 Activity (android.app.Activity)3 QuranSettings (com.quran.labs.androidquran.util.QuranSettings)3 QuranActivity (com.quran.labs.androidquran.ui.QuranActivity)2 List (java.util.List)2 ProgressDialog (android.app.ProgressDialog)1 Context (android.content.Context)1 Intent (android.content.Intent)1 ResolveInfo (android.content.pm.ResolveInfo)1 Uri (android.net.Uri)1 AsyncTask (android.os.AsyncTask)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 Environment (android.os.Environment)1 Preference (android.preference.Preference)1 PreferenceFragment (android.preference.PreferenceFragment)1 PreferenceGroup (android.preference.PreferenceGroup)1 AlertDialog (android.support.v7.app.AlertDialog)1 TextUtils (android.text.TextUtils)1 Toast (android.widget.Toast)1