CometChatMentionsFormatter
class is a part of the CometChat UI Kit, a ready-to-use chat UI component library for integrating CometChat into your Android applications. This class provides functionality to format mentions within text messages displayed in the chat interface. Mentions allow users to reference other users within a conversation, providing a convenient way to direct messages or involve specific participants.
CometChatMentionsFormatter
class into your application:
CometChatMentionsFormatter
class and configure it with desired settings, such as mention text styles and limit settings.
setOnMentionClick
).
prepareLeftMessageBubbleSpan
, prepareRightMessageBubbleSpan
, prepareComposerSpan
, and prepareConversationSpan
methods to format text messages with mentions appropriately for display in the chat interface.
CometChatMentionsFormatter
class in components such as CometChatConversations, CometChatMessageList, CometChatMessageComposer.
Methods | Description | Code |
---|---|---|
setMentionLimit | Sets the limit for the number of mentions allowed. | setMentionLimit(int limit) |
setGroupMembersRequestBuilder | Sets the builder for fetching group members. | .setGroupMembersRequestBuilder(group -> new GroupMembersRequest.GroupMembersRequestBuilder(group.getGuid())); |
setUsersRequestBuilder | Sets the builder for fetching users. | .setUsersRequestBuilder(new UsersRequest.UsersRequestBuilder().friendsOnly(true)); |
setMentionsType | Supports two types of mentions: USERS and USERS_AND_GROUP_MEMBERS . If set to USERS , only users can be mentioned in both one-on-one and group conversations. If set to USERS_AND_GROUP_MEMBERS , members of a specific group can be mentioned in group chats, while all users can be mentioned in one-on-one chats. | .setMentionsType(UIKitConstants.MentionsType.USERS_AND_GROUP_MEMBERS) |
setMentionsVisibility | This method allows you to set the scope of mentions visibility within the app, choosing from USERS_CONVERSATION_ONLY , GROUP_CONVERSATION_ONLY , or BOTH . It lets you specify whether mentions are visible only in one-on-one conversations, only in group conversations, or in both. | .setMentionsVisibility(UIKitConstants.MentionsVisibility.BOTH); |
setOnMentionClick | Sets a listener for mention click in Message Bubbles events. | mentionFormatter.setOnMentionClick((context, user) -> { // Add your implementation here }); |