protected void loadData () { final List<User> list = ChatSDK.contact().contacts(); // Removing the users that is already inside the thread. if (mode == MODE_ADD_TO_CONVERSATION && !threadEntityID.equals("")){ thread = StorageManager.shared().fetchThreadWithEntityID(threadEntityID); List<User> threadUser = thread.getUsers(); list.removeAll(threadUser); } List<UserListItem> items = new ArrayList<>(); for(User u : list) { items.add(u); } adapter.setUsers(items, true); }
final List<User> existingContacts = ChatSDK.contact().contacts();
protected Completable reloadUsers () { return Completable.create(e -> { if (loadingMode != MODE_USE_SOURCE) { sourceUsers.clear(); // If this is not a dialog we will load the contacts of the user. switch (loadingMode) { case MODE_LOAD_CONTACTS: sourceUsers.addAll(ChatSDK.contact().contacts()); Timber.d("Contacts: " + sourceUsers.size()); break; case MODE_LOAD_THREAD_USERS: Thread thread = DaoCore.fetchEntityWithEntityID(Thread.class, extraData); // Remove the current user from the list. List<User> users = thread.getUsers(); users.remove(ChatSDK.currentUser()); sourceUsers.addAll(users); break; case MODE_LOAD_CONTACT_THAT_NOT_IN_THREAD: List<User> users1 = ChatSDK.contact().contacts(); thread = StorageManager.shared().fetchThreadWithID((Long) extraData); List<User> threadUser = thread.getUsers(); users1.removeAll(threadUser); sourceUsers.addAll(users1); break; } } e.onComplete(); }).subscribeOn(Schedulers.single()); }
private Completable contactsMetaOn () { return Completable.create(e -> { ArrayList<Completable> completables = new ArrayList<>(); for (User contact : ChatSDK.contact().contacts()) { completables.add(ChatSDK.core().userOn(contact)); } Completable.merge(completables).subscribe(e::onComplete, throwable -> e.onError(throwable)); }).subscribeOn(Schedulers.single()); }
public void userOff(final String entityID){ isOn = false; final User user = DaoCore.fetchEntityWithEntityID(User.class, entityID); FirebaseReferenceManager.shared().removeListeners(FirebasePaths.userThreadsRef(entityID)); FirebaseReferenceManager.shared().removeListeners(FirebasePaths.publicThreadsRef()); FirebaseReferenceManager.shared().removeListeners(FirebasePaths.userFollowersRef(entityID)); FirebaseReferenceManager.shared().removeListeners(FirebasePaths.userFollowingRef(entityID)); ThreadWrapper wrapper; for (Thread thread : ChatSDK.thread().getThreads(ThreadType.All)) { wrapper = new ThreadWrapper(thread); wrapper.off(); wrapper.messagesOff(); wrapper.usersOff(); } for (User contact : ChatSDK.contact().contacts()) { UserWrapper.initWithModel(contact).metaOff(); } if (ChatSDK.push() != null) { ChatSDK.push().unsubscribeToPushChannel(user.getPushChannel()); } disposableList.dispose(); }