use of chat.rocket.persistence.realm.repositories.RealmMessageRepository in project Rocket.Chat.Android by RocketChat.
the class MessageOptionsDialogFragment method setUpDialog.
private void setUpDialog(final BottomSheetDialog bottomSheetDialog, String messageId) {
RocketChatCache cache = new RocketChatCache(bottomSheetDialog.getContext());
String hostname = cache.getSelectedServerHostname();
EditMessageInteractor editMessageInteractor = getEditMessageInteractor(hostname);
MessageRepository messageRepository = new RealmMessageRepository(hostname);
Disposable disposable = messageRepository.getById(messageId).flatMap(it -> {
if (!it.isPresent()) {
return Single.just(Pair.<Message, Boolean>create(null, false));
}
Message message = it.get();
return Single.zip(Single.just(message), editMessageInteractor.isAllowed(message), Pair::create);
}).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(pair -> {
if (pair.second) {
bottomSheetDialog.findViewById(R.id.message_options_info).setVisibility(View.GONE);
View editView = bottomSheetDialog.findViewById(R.id.message_options_edit_action);
editView.setVisibility(View.VISIBLE);
editView.setOnClickListener(view -> internalListener.onEdit(pair.first));
} else {
((TextView) bottomSheetDialog.findViewById(R.id.message_options_info)).setText(R.string.message_options_no_permissions_info);
}
}, throwable -> {
((TextView) bottomSheetDialog.findViewById(R.id.message_options_info)).setText(R.string.message_options_no_message_info);
Logger.report(throwable);
});
compositeDisposable.add(disposable);
}
use of chat.rocket.persistence.realm.repositories.RealmMessageRepository 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 chat.rocket.persistence.realm.repositories.RealmMessageRepository in project Rocket.Chat.Android by RocketChat.
the class MessageOptionsDialogFragment method getEditMessageInteractor.
private EditMessageInteractor getEditMessageInteractor(String hostname) {
UserRepository userRepository = new RealmUserRepository(hostname);
RoomRoleRepository roomRoleRepository = new RealmRoomRoleRepository(hostname);
PermissionRepository permissionRepository = new RealmPermissionRepository(hostname);
PermissionInteractor permissionInteractor = new PermissionInteractor(userRepository, roomRoleRepository, permissionRepository);
MessageRepository messageRepository = new RealmMessageRepository(hostname);
RoomRepository roomRepository = new RealmRoomRepository(hostname);
PublicSettingRepository publicSettingRepository = new RealmPublicSettingRepository(hostname);
return new EditMessageInteractor(permissionInteractor, userRepository, messageRepository, roomRepository, publicSettingRepository);
}
use of chat.rocket.persistence.realm.repositories.RealmMessageRepository in project Rocket.Chat.Android by RocketChat.
the class RoomFragment method onCreate.
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
hostname = args.getString(HOSTNAME);
roomId = args.getString(ROOM_ID);
roomRepository = new RealmRoomRepository(hostname);
MessageInteractor messageInteractor = new MessageInteractor(new RealmMessageRepository(hostname), roomRepository);
userRepository = new RealmUserRepository(hostname);
absoluteUrlHelper = new AbsoluteUrlHelper(hostname, new RealmServerInfoRepository(), userRepository, new SessionInteractor(new RealmSessionRepository(hostname)));
methodCallHelper = new MethodCallHelper(getContext(), hostname);
presenter = new RoomPresenter(roomId, userRepository, messageInteractor, roomRepository, absoluteUrlHelper, methodCallHelper, ConnectivityManager.getInstance(getContext()));
if (savedInstanceState == null) {
presenter.loadMessages();
}
}
Aggregations