use of io.reactivex.disposables.Disposable in project Rocket.Chat.Android by RocketChat.
the class RoomFragment method setupMessageComposer.
private void setupMessageComposer() {
final MessageFormLayout messageFormLayout = (MessageFormLayout) rootView.findViewById(R.id.message_composer);
messageFormManager = new MessageFormManager(messageFormLayout, this::showExtraActionSelectionDialog);
messageFormManager.setSendMessageCallback(this::sendMessage);
messageFormLayout.setEditTextCommitContentListener(this::onCommitContent);
autocompleteManager = new AutocompleteManager((ViewGroup) rootView.findViewById(R.id.message_list_root));
autocompleteManager.registerSource(new ChannelSource(new AutocompleteChannelInteractor(roomRepository, new RealmSpotlightRoomRepository(hostname), new DeafultTempSpotlightRoomCaller(methodCallHelper)), AndroidSchedulers.from(BackgroundLooper.get()), AndroidSchedulers.mainThread()));
Disposable disposable = Single.zip(absoluteUrlHelper.getRocketChatAbsoluteUrl(), roomRepository.getById(roomId).first(Optional.absent()), Pair::create).subscribe(pair -> {
if (pair.first.isPresent() && pair.second.isPresent()) {
autocompleteManager.registerSource(new UserSource(new AutocompleteUserInteractor(pair.second.get(), userRepository, new RealmMessageRepository(hostname), new RealmSpotlightUserRepository(hostname), new DefaultTempSpotlightUserCaller(methodCallHelper)), pair.first.get(), RocketChatUserStatusProvider.getInstance(), AndroidSchedulers.from(BackgroundLooper.get()), AndroidSchedulers.mainThread()));
}
}, throwable -> {
});
compositeDisposable.add(disposable);
autocompleteManager.bindTo(messageFormLayout.getEditText(), messageFormLayout);
}
use of io.reactivex.disposables.Disposable in project Rocket.Chat.Android by RocketChat.
the class RoomPresenter method onUnreadCount.
@Override
public void onUnreadCount() {
final Disposable subscription = getRoomUserPair().flatMap(roomUserPair -> messageInteractor.unreadCountFor(roomUserPair.first, roomUserPair.second)).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(count -> view.showUnreadCount(count), Logger::report);
addSubscription(subscription);
}
use of io.reactivex.disposables.Disposable in project Rocket.Chat.Android by RocketChat.
the class RoomPresenter method getMessages.
private void getMessages() {
final Disposable subscription = roomRepository.getById(roomId).filter(Optional::isPresent).map(Optional::get).flatMap(messageInteractor::getAllFrom).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(messages -> view.showMessages(messages), Logger::report);
addSubscription(subscription);
}
use of io.reactivex.disposables.Disposable in project Rocket.Chat.Android by RocketChat.
the class RoomPresenter method getUserPreferences.
private void getUserPreferences() {
final Disposable subscription = userRepository.getCurrent().filter(Optional::isPresent).map(Optional::get).filter(user -> user.getSettings() != null).map(User::getSettings).filter(settings -> settings.getPreferences() != null).map(Settings::getPreferences).distinctUntilChanged().subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(preferences -> {
if (preferences.isAutoImageLoad()) {
view.autoloadImages();
} else {
view.manualLoadImages();
}
}, Logger::report);
addSubscription(subscription);
}
use of io.reactivex.disposables.Disposable in project RxRelay by JakeWharton.
the class ReplayRelayTest method testSubscriptionLeak.
@Test
public void testSubscriptionLeak() {
ReplayRelay<Object> subject = ReplayRelay.create();
Disposable s = subject.subscribe();
assertEquals(1, subject.observerCount());
s.dispose();
assertEquals(0, subject.observerCount());
}
Aggregations