Class ReferenceManager

    • Constructor Detail

      • ReferenceManager

        ReferenceManager()
    • Method Detail

      • onInit

         void onInit(Context context, String appKey)

        SDK initialization. Users can register custom messages, message templates, and initialize their own modules in this method.

        Parameters:
        context - Context.
        appKey - Unique application key.
      • onAttachedToExtension

         void onAttachedToExtension(Fragment fragment, NCExtension extension)

        After entering a conversation, Extension loads all registered modules. Modules can hold and use the Extension. Note: if a module holds an Extension object, it must release it in the onDetachedFromExtension callback to avoid memory leaks.

        Parameters:
        fragment - The fragment where the Extension object resides.
        extension - The Extension object.
      • onDetachedFromExtension

         void onDetachedFromExtension()

        Called when leaving a conversation; Extension releases all loaded modules. Note: if a module holds an Extension object, it must release it in this callback to avoid memory leaks.

      • onReceivedMessage

         void onReceivedMessage(Message message)

        After the SDK receives a message, it routes the message to the corresponding module via this method. Users can selectively handle received messages based on their registered message types.

        Parameters:
        message - The message entity.
      • getPluginModules

         List<IPluginModule> getPluginModules(ChannelType channelType)

        Users can configure plugins in the "+" area based on different conversations. One or multiple plugins can be configured; the extension displays all returned plugins. Note: if no plugins are configured, this method does not need to be implemented.

        Parameters:
        channelType - Channel type.
        Returns:

        Plugin list.

      • getEmoticonTabs

         List<IEmoticonTab> getEmoticonTabs()

        Multiple or single emoticon tabs can be configured in a conversation. Once configured, this tab will be displayed in all conversations. Note: if no emoticons are configured, this method does not need to be implemented.

        Returns:

        Emoticon tab list.

      • onTextChanged

         void onTextChanged(Context context, ChannelType type, String targetId, int cursorPos, int count, String text)

        Callback when input field text changes.

        Parameters:
        context - context
        type - channel type
        targetId - target ID
        cursorPos - cursor position
        count - text change count
        text - text content
      • onSendToggleClick

         void onSendToggleClick(Message message)

        Pre-processing when the Extension module's send button is clicked. Other modules can set additional information to Extension through this callback.

        Parameters:
        message - the initial message built when the Extension module's send button is clicked.
      • applyReference

         MessageContent applyReference(TextMessage textMessage)

        Merges the pending TextMessage with the current reference.

        If a reference message exists (reference bar shown above the input), fills the text and MentionedInfo from textMessage into ReferenceMessage, hides the reference bar, and returns the ReferenceMessage; otherwise returns textMessage as-is.

        Parameters:
        textMessage - the plain text message constructed from the input field
        Returns:

        a ReferenceMessage with the reference, or the original textMessage if none

      • showReferenceView

         boolean showReferenceView(Context context, UiMessage uiMessage)

        Shows the reference message bar.

        Parameters:
        context - the context
        uiMessage - the message entity
        Returns:

        whether the display was successful

      • showReferenceView

         boolean showReferenceView(Context context, UiMessage uiMessage, boolean showKeyBoard)

        Shows the reference message bar.

        Parameters:
        context - the context
        uiMessage - the message entity
        Returns:

        whether the display was successful

      • onDeleteClick

         void onDeleteClick(ChannelType type, String targetId, EditText editText, int cursorPos)