Introduction
The ShortCutFormatter class extends the CometChatTextFormatter class to provide a mechanism for handling shortcuts within messages. This guide will walk you through the process of using ShortCutFormatter to implement shortcut extensions in your CometChat application.Setup
- Create the ShortCutFormatter Class: Define the
ShortCutFormatterclass by extending theCometChatTextFormatterclass.
- Java
- Kotlin
- Constructor: Initialize the
messageShortcutsmap andshortcutslist in the constructor.
- Java
- Kotlin
- Prepare Shortcuts: Implement the
prepareShortCuts()method to fetch shortcuts from the server using CometChat extension.
- Java
- Kotlin
- Override Search Method: Override the
search()method to search for shortcuts based on the entered query.
- Java
- Kotlin
- Handle Scroll to Bottom: Override the
onScrollToBottom()method if needed.
- Java
- Kotlin
Usage
- Initialization: Initialize an instance of
ShortCutFormatterin your application.
- Java
- Kotlin
- Integration: Integrating the
ShortCutFormatterinto your CometChat application involves incorporating it within your project to handle message shortcuts. Use MessageComposer component, you can seamlessly integrate the ShortCutFormatter to manage shortcut functionalities within your application.
- XML
- Java
- Kotlin
Example
