AI Integration Quick Reference
AI Integration Quick Reference
Overview
Threaded replies allow users to respond directly to a specific message in one-on-one or group chats, improving context and readability:- Organizes related replies into a dedicated thread view.
- Mirrors functionality in Slack, Discord, and WhatsApp.
- Maintains clarity in active conversations.
Prerequisites
- Android project in Android Studio.
- CometChat Android UI Kit v5 added to your
build.gradle. - Valid CometChat App ID, Auth Key, and Region initialized.
<uses-permission android:name="android.permission.INTERNET"/>inAndroidManifest.xml.- Logged-in user via
CometChat.login(). - Existing
MessagesActivityusingCometChatMessageList.
Components
Integration Steps
Step 1: Add Thread Layout
Createres/layout/activity_thread_message.xml:
activity_thread_message.xml
activity_thread_message.xml
Step 2: Set up ThreadMessageActivity
Initialize UI & handle blocked-user flows:- Kotlin
- Java
ThreadMessageActivity.java
Step 3: Create ThreadMessageViewModel
Store parent message and expose LiveData:- Kotlin
- Java
ThreadMessageViewModel.java
Step 4: Hook Thread Entry from Message List
In yourMessagesActivity, capture thread icon taps:
- Kotlin
- Java
MessagesActivity.java
Implementation Flow
- User taps thread icon on a message.
IntentlaunchesThreadMessageActivitywith raw message JSON.- ViewModel stores parent message and exposes via LiveData.
- Header &
MessageListrender parent + replies. - Composer sends new replies under the parent message.
- Live updates flow automatically via UI Kit.
Customization Options
- Styling: Override theme attributes or call setter methods on views.
- Header Height:
threadHeader.setMaxHeight(...). - Hide Reactions:
threadHeader.setReactionVisibility(View.GONE).
Filtering & Edge Cases
- Group Membership: Verify membership before enabling composer.
- Empty Thread: Show placeholder if no replies.
- Blocked Users: Composer hidden; use unblock layout.
Blocked-User Handling
InUserDetailActivity, detect and toggle UI:
- Kotlin
- Java
UserDetailActivity.java
Group vs. User-Level Differences
Summary / Feature Matrix
Next Steps & Further Reading
Android Sample App (Java)
Explore this feature in the CometChat SampleApp:
GitHub → SampleApp
Android Sample App (Kotlin)
Explore this feature in the CometChat SampleApp:
GitHub → SampleApp