Search in sources :

Example 1 with AutocompleteManager

use of chat.rocket.android.widget.message.autocomplete.AutocompleteManager 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);
}
Also used : CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) RealmSpotlightRoomRepository(chat.rocket.persistence.realm.repositories.RealmSpotlightRoomRepository) AutocompleteChannelInteractor(chat.rocket.core.interactors.AutocompleteChannelInteractor) ViewGroup(android.view.ViewGroup) RealmMessageRepository(chat.rocket.persistence.realm.repositories.RealmMessageRepository) MessageFormLayout(chat.rocket.android.widget.message.MessageFormLayout) AutocompleteUserInteractor(chat.rocket.core.interactors.AutocompleteUserInteractor) RealmSpotlightUserRepository(chat.rocket.persistence.realm.repositories.RealmSpotlightUserRepository) DefaultTempSpotlightUserCaller(chat.rocket.android.service.temp.DefaultTempSpotlightUserCaller) MessageFormManager(chat.rocket.android.layouthelper.chatroom.MessageFormManager) UserSource(chat.rocket.android.widget.message.autocomplete.user.UserSource) DeafultTempSpotlightRoomCaller(chat.rocket.android.service.temp.DeafultTempSpotlightRoomCaller) AutocompleteManager(chat.rocket.android.widget.message.autocomplete.AutocompleteManager) ChannelSource(chat.rocket.android.widget.message.autocomplete.channel.ChannelSource)

Aggregations

ViewGroup (android.view.ViewGroup)1 MessageFormManager (chat.rocket.android.layouthelper.chatroom.MessageFormManager)1 DeafultTempSpotlightRoomCaller (chat.rocket.android.service.temp.DeafultTempSpotlightRoomCaller)1 DefaultTempSpotlightUserCaller (chat.rocket.android.service.temp.DefaultTempSpotlightUserCaller)1 MessageFormLayout (chat.rocket.android.widget.message.MessageFormLayout)1 AutocompleteManager (chat.rocket.android.widget.message.autocomplete.AutocompleteManager)1 ChannelSource (chat.rocket.android.widget.message.autocomplete.channel.ChannelSource)1 UserSource (chat.rocket.android.widget.message.autocomplete.user.UserSource)1 AutocompleteChannelInteractor (chat.rocket.core.interactors.AutocompleteChannelInteractor)1 AutocompleteUserInteractor (chat.rocket.core.interactors.AutocompleteUserInteractor)1 RealmMessageRepository (chat.rocket.persistence.realm.repositories.RealmMessageRepository)1 RealmSpotlightRoomRepository (chat.rocket.persistence.realm.repositories.RealmSpotlightRoomRepository)1 RealmSpotlightUserRepository (chat.rocket.persistence.realm.repositories.RealmSpotlightUserRepository)1 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 Disposable (io.reactivex.disposables.Disposable)1