public Completable addUsersToThread(Thread thread, User... users) { return addUsersToThread(thread, Arrays.asList(users)); }
public Single<Thread> createThread(List<User> users) { return createThread(null, users); }
public List<Thread> getThreads(int type) { return getThreads(type, false); }
/** * Preparing a text message, * This is only the build part of the send from here the message will passed to "sendMessage" Method. * From there the message will be uploaded to the server if the upload fails the message will be deleted from the local db. * If the upload is successful we will update the message entity so the entityId given from the server will be saved. * The message will be received before sending in the onMainFinished Callback with a Status that its in the sending process. * When the message is fully sent the status will be changed and the onItem callback will be invoked. * When done or when an error occurred the calling method will be notified. */ public Observable<MessageSendProgress> sendMessageWithText(final String text, final Thread thread) { return Observable.create((ObservableOnSubscribe<MessageSendProgress>) e -> { final Message message = newMessage(MessageType.Text, thread); message.setText(text); e.onNext(new MessageSendProgress(message)); ObservableConnector<MessageSendProgress> connector = new ObservableConnector<>(); connector.connect(implSendMessage(message), e); }).subscribeOn(Schedulers.single()); }
public static Message newMessage (MessageType type, Thread thread) { return newMessage(type.ordinal(), thread); }
public Completable removeUsersFromThread(Thread thread, User... users) { return removeUsersFromThread(thread, Arrays.asList(users)); }
public Single<List<Message>> loadMoreMessagesForThread(final Message fromMessage, final Thread thread) { return super.loadMoreMessagesForThread(fromMessage, thread).flatMap(messages -> { if (messages.isEmpty()) { return new ThreadWrapper(thread).loadMoreMessages(fromMessage, ChatSDK.config().messagesToLoadPerBatch); } return Single.just(messages); }); }
/** /* Convenience method to save the message to the database then pass it to the token network adapter * send method so it can be sent via the network */ public Observable<MessageSendProgress> implSendMessage(final Message message) { return Observable.create((ObservableOnSubscribe<MessageSendProgress>) e -> { message.update(); message.getThread().update(); if (ChatSDK.encryption() != null) { ChatSDK.encryption().encrypt(message); } e.onNext(new MessageSendProgress(message)); e.onComplete(); }).concatWith(sendMessage(message)) .subscribeOn(Schedulers.single()).doOnComplete(() -> { message.setMessageStatus(MessageSendStatus.Sent); message.update(); }).doOnError(throwable -> { message.setMessageStatus(MessageSendStatus.Failed); message.update(); }); }
return Observable.create((ObservableOnSubscribe<MessageSendProgress>) e -> { final Message message = AbstractThreadHandler.newMessage(MessageType.Image, thread);
public List<Thread> getThreads(int type, boolean allowDeleted) { return getThreads(type, allowDeleted, ChatSDK.config().showEmptyChats); }
public Observable<MessageSendProgress> sendMessageWithLocation(final String filePath, final LatLng location, final Thread thread) { return Observable.create((ObservableOnSubscribe<MessageSendProgress>) e -> { final Message message = AbstractThreadHandler.newMessage(MessageType.Location, thread);
public Single<Thread> createThread(String name, User... users) { return createThread(name, Arrays.asList(users)); }
public int getUnreadMessagesAmount(boolean onePerThread){ List<Thread> threads = getThreads(ThreadType.Private, false); int count = 0; for (Thread t : threads) { if (onePerThread) { if(!t.isLastMessageWasRead()) { count++; } } else { count += t.getUnreadMessagesCount(); } } return count; }