ThreadedMessages is a Composite Component that displays all replies made to a particular message in a conversation. By default, the parent message will be displayed at the top, the message composer will be at the bottom and between them a message list will contain all replies.
ThreadedMessages is composed of the following components:
Actions dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.ThreadedMessages does not have its own actions. However, you can override the behavior of the ThreadedMessages component by using the actions of its Components, with the help of Configurations.ExampleIn this example, we are overriding the onThreadReplyClick of the MessageList Component using MessageListConfiguration and applying it to ThreadedMessages.
Java
Kotlin
MessageListConfiguration configuration = new MessageListConfiguration();configuration.setOnThreadRepliesClick(new CometChatMessageList.ThreadReplyClick() { @Override public void onThreadReplyClick(Context context, BaseMessage baseMessage, CometChatMessageTemplate cometChatMessageTemplate, CometChatMessageBubble cometChatMessageBubble) { }});threadedMessages.setMessageListConfiguration(configuration);
Filters allow you to customize the data displayed in a list within a Component. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of Chat SDK.ThreadedMessages does not have its own Filters. However, you can filter the messages list in ThreadedMessages Component using MessageListConfiguration.ExampleIn this example, we are filtering messages based on the ParentMessageID and searching for messages that contain the keyword “payment”.
Java
Kotlin
MessageListConfiguration configuration = new MessageListConfiguration();MessagesRequest.MessagesRequestBuilder builder = new MessagesRequest.MessagesRequestBuilder().setParentMessageId(213).setSearchKeyword("payment");configuration.setMessagesRequestBuilder(builder);threadedMessages.setMessageListConfiguration(configuration);
Events are emitted by a Component. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.The MessageList Component does not emit any events of its own.
To fit your app’s design requirements, you can customize the appearance of the conversation component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.
Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.
1. ThreadedMessage Style
To modify the styling, you can apply the ThreadedMessageStyle to the ThreadedMessage Component using the setStyle method.
Java
Kotlin
ThreadedMessagesStyle style = new ThreadedMessagesStyle();threadedMessages.setStyle(style)
val style = ThreadedMessagesStyle()threadedMessages.setStyle(style)
The following properties are exposed by ThreadedMessagesStyle:
Methods
Type
Description
setBackground
@ColorInt int
used to set the background color
setBorderWidth
int
used to set border
borderRadius
double
used to set border radius
setBackground
Drawable
used to set background gradient
setTitleAppearance
@StyleRes int
used to customise the appearance of the title in the app bar
setCloseIconTint
@ColorInt int
used to set the color of the close icon in the app bar
These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements.
For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.
By using setMessageBubbleView(), You can set parent message buggle view inside ThreadedMessage Component.
Java
Kotlin
threadedMessages.setMessageBubbleView()
threadedMessages.setMessageBubbleView()
Example
In this example, we will set parent message view which we get from setOnThreadRepliesClick Action of MessageList Component and apply custom styles on it.
You can set your custom message list view using the setMessageListView() method. But keep in mind, by using this you will override the default message ListView functionality.
Java
Kotlin
threadedMessages.setMessageListView()
threadedMessages.setMessageListView()
Example
In this example, we will create a custom_messages_list_layout.xml and inflate it inside the setMessageListView() method.
You can set your custom Message Composer view using the setMessageComposerView() method. But keep in mind, by using this you will override the default message composer functionality.
Java
Kotlin
threadedMessages.setMessageComposerView()
threadedMessages.setMessageComposerView()
Example
In this example, we will create a custom_composer_view_layout.xml and inflate it inside the setMessageComposerView() method.
Configurations offer the ability to customize the properties of each individual component within a Composite Component.The ThreadedMessages is a Composite Component, and it has a distinct set of configurations for each of its components as follows.
If you want to customize the properties of the MessageList Component inside ThreadedMessages Component, you need use the MessageListConfiguration object.
Java
Kotlin
MessageListConfiguration messageListConfiguration = new MessageListConfiguration();threadedMessages.setMessageListConfiguration(messageListConfiguration);
val messageListConfiguration = MessageListConfiguration()threadedMessages.setMessageListConfiguration(messageListConfiguration)
Please note that the properties marked with the 🛑 symbol are not accessible within the Configuration Object.
Example
In this example, we will be changing the list alignment and modifying the message bubble styles in the MessageList component using MessageListConfiguration.
Java
Kotlin
MessageListConfiguration messageListConfiguration = new MessageListConfiguration();messageListConfiguration.setListAlignment(UIKitConstants.MessageListAlignment.LEFT_ALIGNED);MessageBubbleStyle messageBubbleStyle= new MessageBubbleStyle();messageBubbleStyle.setCornerRadius(20f);messageBubbleStyle.setBorderColor(R.color.purple_700);messageBubbleStyle.setBorderWidth(5);messageListConfiguration.setWrapperMessageBubbleStyle(messageBubbleStyle);threadedMessages.setMessageListConfiguration(messageListConfiguration);
If you want to customize the properties of the MessageComposer Component inside ThreadedMessages Component, you need use the MessageComposerConfiguration object.
Java
Kotlin
MessageComposerConfiguration configuration = new MessageComposerConfiguration();threadedMessages.setMessageComposerConfiguration(configuration);
val configuration = MessageComposerConfiguration()threadedMessages.setMessageComposerConfiguration(configuration)
Please note that the properties marked with the 🛑 symbol are not accessible within the Configuration Object.
Example
In this example, we’ll be adding a custom header view and customizing some properties of the MessageComposer component using MessageComposerConfiguration.
Java
Kotlin
MessageComposerConfiguration configuration = new MessageComposerConfiguration();View view = getLayoutInflater().inflate(R.layout.custom_header_view_layout, null);configuration.setHeaderView(view);MessageComposerStyle composerStyle = new MessageComposerStyle();composerStyle.setBorderColor(Color.LTGRAY);composerStyle.setBorderWidth(5);composerStyle.setCornerRadius(20);configuration.setStyle(composerStyle);threadedMessages.setMessageComposerConfiguration(configuration);