@Override protected List<Thread> getThreads() { return ChatSDK.thread().getThreads(ThreadType.Public); } }
public boolean onLongClick (View v) { if (onLongClickListener != null) { onLongClickListener.onLongClick(v); } else if (message != null && !message.getSender().isMe()) { Context context = v.getContext(); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(itemView.getContext().getString(R.string.delete_message)); // Set up the buttons builder.setPositiveButton(context.getString(R.string.delete), (dialog, which) -> { try { ChatSDK.thread().deleteMessage(message).subscribe( new CrashReportingCompletableObserver()); } catch (NoSuchMethodError e) { ChatSDK.logError(e); } }); builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.cancel()); builder.show(); } return false; }
@Override public void initViews() { super.initViews(); Disposable d = adapter.onLongClickObservable().subscribe(thread -> DialogUtils.showToastDialog(getContext(), "", getResources().getString(R.string.alert_delete_thread), getResources().getString(R.string.delete), getResources().getString(R.string.cancel), null, () -> { ChatSDK.thread().deleteThread(thread) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new CompletableObserver() { @Override public void onSubscribe(Disposable d) { } @Override public void onComplete() { adapter.clearData(); reloadData(); ToastHelper.show(getContext(), getString(R.string.delete_thread_success_toast)); } @Override public void onError(Throwable e) { ToastHelper.show(getContext(), getString(R.string.delete_thread_fail_toast)); } }); return null; })); }
/** * Sending a broadcast that the chat was closed, Only if there were new messages on this chat. * This is used for example to update the thread list that messages has been read. */ @Override protected void onStop() { super.onStop(); disposableList.dispose(); stopTyping(true); markRead(); if (thread != null && thread.typeIs(ThreadType.Public) && removeUserFromChatOnExit) { ChatSDK.thread().removeUsersFromThread(thread, ChatSDK.currentUser()).observeOn(AndroidSchedulers.mainThread()).subscribe(new CrashReportingCompletableObserver()); } }
ChatSDK.thread().addUsersToThread(thread, users) .observeOn(AndroidSchedulers.mainThread()) .subscribe(() -> {
protected Single<Thread> createAndOpenThread (String name, List<User> users) { return ChatSDK.thread().createThread(name, users) .observeOn(AndroidSchedulers.mainThread()) .doOnSuccess(thread -> { if (thread != null) { ChatSDK.ui().startChatActivityForID(getApplicationContext(), thread.getEntityID()); } }).doOnError(throwable -> ToastHelper.show(getApplicationContext(), R.string.create_thread_with_users_fail_toast)); }
Disposable d = ChatSDK.thread().loadMoreMessagesForThread(null, thread) .observeOn(AndroidSchedulers.mainThread()) .subscribe((messages, throwable) -> {
/** * Send text message * * @param text to send. * @param clearEditText if true clear the message edit text. */ public void sendMessage(String text, boolean clearEditText) { if (StringUtils.isEmpty(text) || StringUtils.isBlank(text)) { return; } handleMessageSend(ChatSDK.thread().sendMessageWithText(text.trim(), thread)); if (clearEditText && textInputView != null) { textInputView.clearText(); } stopTyping(false); scrollListTo(ListPosition.Bottom, false); }
connector.connect(ChatSDK.thread().sendMessage(message), e);
ChatSDK.thread().removeUsersFromThread(model, currentUser).subscribe(e::onComplete, e::onError);
ChatSDK.thread().addUsersToThread(thread, currentUser) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new CrashReportingCompletableObserver(disposableList));
public void startChat () { if (startingChat) { return; } startingChat = true; showProgressDialog(getString(R.string.creating_thread)); disposableList.add(ChatSDK.thread().createThread("", user, ChatSDK.currentUser()) .observeOn(AndroidSchedulers.mainThread()) .doFinally(() -> { dismissProgressDialog(); startingChat = false; }) .subscribe(thread -> { ChatSDK.ui().startChatActivityForID(getApplicationContext(), thread.getEntityID()); }, throwable -> { ToastHelper.show(getApplicationContext(), throwable.getLocalizedMessage()); })); }
disposableList.add(ChatSDK.thread().loadMoreMessagesForThread(firstMessage, thread) .observeOn(AndroidSchedulers.mainThread()) .subscribe((messages, throwable) -> {
@Override protected List<Thread> getThreads() { return ChatSDK.thread().getThreads(ThreadType.Private); }
ChatSDK.thread().addUsersToThread(thread, clickedUser) .observeOn(AndroidSchedulers.mainThread()) .subscribe(() -> {
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(); }
for(Thread thread : ChatSDK.thread().getThreads(ThreadType.Public)) { for(User u : thread.getUsers()) { thread.removeUser(u);