Architecture
Each component is composed of three collaborating classes:| Layer | Role | Example Class |
|---|---|---|
| View | Renders the UI, handles user interaction, and exposes setter methods for customization. | CometChatConversations |
| ViewModel | Manages data fetching, state, and business logic via LiveData. | ConversationsViewModel |
| Adapter | Binds data to RecyclerView items and controls how each list row is rendered. | ConversationsAdapter |
Accessing Internal Layers
The View layer provides accessor methods to reach the other layers:| Method | Returns | Purpose |
|---|---|---|
getViewModel() | ConversationsViewModel | Access the ViewModel to observe LiveData, call mutation methods, or configure request builders. |
getConversationsAdapter() | ConversationsAdapter | Access the Adapter to manipulate list data or set view slots directly on the adapter. |
getRecyclerView() | RecyclerView | Access the underlying RecyclerView for scroll listeners, layout manager changes, or item decorations. |
getBinding() | CometchatConversationsListViewBinding | Access the ViewBinding for direct manipulation of the component’s internal views. |
- Kotlin
- Java
Customization Categories
The UI Kit provides eight categories of customization entry points. Each category has a dedicated guide:View Slots
Replace specific regions of a component’s UI (leading view, title, subtitle, trailing view) using the ViewHolderListener pattern.
Styles
Customize visual appearance using XML theme attributes or programmatic setter methods on the View layer.
ViewModel & Data
Configure data fetching with RequestBuilders, observe LiveData, and call mutation methods on the ViewModel.
Adapters
Access or replace the RecyclerView Adapter to control how list items are rendered and manage list data.
Events & Callbacks
Handle click events, selection mode, and global UI Kit events with component-level and static event listeners.
State Views
Replace or restyle the default empty, error, and loading state views with custom layouts.
Text Formatters
Create custom text processors for hashtags, mentions, links, or any pattern using the CometChatTextFormatter API.
Menu & Options
Add, replace, or extend context menu actions and composer attachment options on components.