Class ReferenceManager
-
- All Implemented Interfaces:
-
ai.nexconn.chatui.channel.extension.IExtensionModule,ai.nexconn.chatui.channel.feature.mention.IExtensionEventWatcher
public class ReferenceManager implements IExtensionModule, IExtensionEventWatcher
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceReferenceManager.ReferenceStatusListener
-
Constructor Summary
Constructors Constructor Description ReferenceManager()
-
Method Summary
Modifier and Type Method Description static ReferenceManagergetInstance()voidsetReferenceStatusListener(ReferenceManager.ReferenceStatusListener listener)voidremoveReferenceStatusListener(ReferenceManager.ReferenceStatusListener listener)voidonInit(Context context, String appKey)SDK initialization. voidonAttachedToExtension(Fragment fragment, NCExtension extension)After entering a conversation, Extension loads all registered modules. voidonDetachedFromExtension()Called when leaving a conversation; Extension releases all loaded modules. voidonReceivedMessage(Message message)After the SDK receives a message, it routes the message to the corresponding module via this method. List<IPluginModule>getPluginModules(ChannelType channelType)Users can configure plugins in the "+" area based on different conversations. List<IEmoticonTab>getEmoticonTabs()Multiple or single emoticon tabs can be configured in a conversation. voidonDisconnect()SDK disconnected. voidonTextChanged(Context context, ChannelType type, String targetId, int cursorPos, int count, String text)Callback when input field text changes. voidonSendToggleClick(Message message)Pre-processing when the Extension module's send button is clicked. MessageContentapplyReference(TextMessage textMessage)Merges the pending TextMessage with the current reference. voidonDestroy(ChannelType type, String targetId)booleanshowReferenceView(Context context, UiMessage uiMessage)Shows the reference message bar. booleanshowReferenceViewInEditMode(Context context, UiMessage uiMessage)booleanshowReferenceView(Context context, UiMessage uiMessage, boolean showKeyBoard)Shows the reference message bar. voidhideReferenceView()voidonDeleteClick(ChannelType type, String targetId, EditText editText, int cursorPos)UiMessagegetUiMessage()-
-
Method Detail
-
getInstance
static ReferenceManager getInstance()
-
setReferenceStatusListener
void setReferenceStatusListener(ReferenceManager.ReferenceStatusListener listener)
-
removeReferenceStatusListener
void removeReferenceStatusListener(ReferenceManager.ReferenceStatusListener listener)
-
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.
-
onDisconnect
void onDisconnect()
SDK disconnected.
-
onTextChanged
void onTextChanged(Context context, ChannelType type, String targetId, int cursorPos, int count, String text)
Callback when input field text changes.
- Parameters:
context- contexttype- channel typetargetId- target IDcursorPos- cursor positioncount- text change counttext- 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 contextuiMessage- the message entity- Returns:
whether the display was successful
-
showReferenceViewInEditMode
boolean showReferenceViewInEditMode(Context context, UiMessage uiMessage)
-
showReferenceView
boolean showReferenceView(Context context, UiMessage uiMessage, boolean showKeyBoard)
Shows the reference message bar.
- Parameters:
context- the contextuiMessage- the message entity- Returns:
whether the display was successful
-
hideReferenceView
void hideReferenceView()
-
onDeleteClick
void onDeleteClick(ChannelType type, String targetId, EditText editText, int cursorPos)
-
getUiMessage
UiMessage getUiMessage()
-
-
-
-