Package io.rong.imkit.conversation.messgelist.viewmodel

## Class MessageViewModel

- All Implemented Interfaces:

      public class MessageViewModel

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `public final static int` | `DEFAULT_COUNT` |
    `public final static int` | `DEFAULT_REMOTE_COUNT` |
    `public final static int` | `SHOW_UNREAD_MESSAGE_COUNT` |
    `public static Array<String>` | `writePermission` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `MessageViewModel(Application application)` |

  - ### Enum Constant Summary

    Enum Constants
    Enum Constant | Description
    --- | ---

  - ### Method Summary

    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `bindConversation(ConversationIdentifier conversationIdentifier, Bundle bundle)` |
    `void` | `onGetHistoryMessage(List<Message> messages, boolean isHasMoreMsg)` | 初始化加载本地消息 下拉加载历史消息
    `void` | `onGetHistoryMessage(List<Message> messages)` | 初始化加载本地消息 下拉加载历史消息
    `UiMessage` | `mapUIMessage(Message message)` |
    `void` | `processHistoryDividerMessage()` |
    `void` | `refreshAllMessage()` |
    `Message` | `getFirstUnreadMessage()` |
    `void` | `setFirstUnreadMessage(Message firstUnreadMessage)` |
    `int` | `findPositionByMessageId(int messageId)` |
    `String` | `getCurTargetId()` |
    `ConversationType` | `getCurConversationType()` |
    `ConversationIdentifier` | `getConversationIdentifier()` |
    `void` | `refreshAllMessage(boolean force)` |
    `void` | `onLoadMoreMessage(List<Message> messages)` | 上拉加载更多消息
    `void` | `onReloadMessage(List<Message> messages)` | normal状态点击历史消息bar history状态点击新消息bar
    `MediatorLiveData<PageEvent>` | `getPageEventLiveData()` |
    `void` | `onWarnClick(UiMessage uiMessage)` |
    `void` | `onItemClick(UiMessage uiMessage)` |
    `boolean` | `onItemLongClick(UiMessage uiMessage)` |
    `void` | `onUserPortraitClick(Context context, ConversationType conversationType, UserInfo userInfo, String targetId)` |
    `boolean` | `onUserPortraitLongClick(Context context, ConversationType conversationType, UserInfo userInfo, String targetId)` |
    `void` | `reSendMessage(Message message)` |
    `void` | `onAudioClick(UiMessage uiMessage)` |
    `boolean` | `onBackPressed()` |
    `void` | `quitEditMode()` | 退出编辑模式
    `UiMessage` | `findUIMessage(String messageUId)` |
    `void` | `onSendMessage(SendEvent event)` |
    `void` | `onSendMediaMessage(SendMediaEvent event)` |
    `void` | `onDownloadMessage(DownloadEvent event)` |
    `void` | `onDeleteMessage(DeleteEvent event)` |
    `void` | `onRecallEvent(RecallEvent event)` |
    `void` | `onRefreshEvent(RefreshEvent event)` |
    `void` | `onInsertMessage(InsertEvent event)` |
    `void` | `onClearMessages(ClearEvent event)` |
    `UiMessage` | `findUIMessage(int messageId)` |
    `void` | `removeUIMessage(int messageId)` |
    `void` | `refreshSingleMessage(UiMessage uiMessage)` |
    `int` | `findPositionBySendTime(long sentTime)` |
    `void` | `executePageEvent(PageEvent pageEvent)` |
    `void` | `processNewMessageUnread(boolean isMainThread)` |
    `void` | `updateNewMentionMessageUnreadBar()` |
    `void` | `hideHistoryBar()` |
    `int` | `getRefreshMessageId()` |
    `long` | `getRefreshSentTime()` |
    `long` | `getLoadMoreSentTime()` |
    `boolean` | `isRemoteMessageLoadFinish()` |
    `void` | `setRemoteMessageLoadFinish(boolean remoteMessageLoadFinish)` |
    `boolean` | `isScrollToBottom()` |
    `void` | `setScrollToBottom(boolean scrollToBottom)` |
    `void` | `updateMentionMessage(Message message)` |
    `void` | `executePostPageEvent(PageEvent pageEvent)` | 异步线程切换到主线程执行
    `void` | `onReadReceiptRequestClick(UiMessage uiMessage)` |
    `void` | `onReadReceiptStateClick(UiMessage uiMessage)` |
    `void` | `onReEditClick(UiMessage uiMessage)` |
    `void` | `onRefresh()` |
    `void` | `cleanUnreadNewCount()` |
    `void` | `addUnreadNewMessage(UiMessage message)` |
    `void` | `newMessageBarClick()` |
    `void` | `unreadBarClick()` |
    `void` | `newMentionMessageBarClick()` |
    `void` | `enterEditState()` | 启动编辑模式
    `void` | `forwardMessage(Intent data)` |
    `List<UiMessage>` | `getSelectedUiMessages()` |
    `void` | `onLoadMore()` |
    `boolean` | `isForegroundActivity()` |
    `void` | `onViewClick(int clickType, UiMessage data)` |
    `boolean` | `onViewLongClick(int clickType, UiMessage data)` |
    `LiveData<List<UiMessage>>` | `getUiMessageLiveData()` |
    `MediatorLiveData<Integer>` | `getNewMessageUnreadLiveData()` |
    `MediatorLiveData<Boolean>` | `IsEditStatusLiveData()` |
    `List<UiMessage>` | `getNewUnReadMessages()` |
    `List<Message>` | `getNewUnReadMentionMessages()` |
    `void` | `setNewUnReadMentionMessages(List<Message> newUnReadMentionMessages)` |
    `void` | `showHistoryBar(int unreadMessageCount)` |
    `LiveData<Integer>` | `getHistoryMessageUnreadLiveData()` |
    `void` | `showNewMentionMessageBar(int unreadMessageCount)` |
    `void` | `hideNewMentionMessageBar()` |
    `LiveData<Integer>` | `getNewMentionMessageUnreadLiveData()` |
    `void` | `onScrolled(RecyclerView recyclerView, int dx, int dy, int headerCount, int footerCount)` |
    `List<UiMessage>` | `getUiMessages()` |
    `void` | `onExistUnreadMessage(Conversation conversation, int unreadMessageCount)` |
    `void` | `onResume()` |
    `void` | `cleanUnreadStatus()` | 清理未读状态
    `boolean` | `isInitUnreadMessageFinish()` |
    `void` | `setInitUnreadMessageFinish(boolean initUnreadMessageFinish)` |
    `boolean` | `isInitMentionedMessageFinish()` |
    `void` | `setInitMentionedMessageFinish(boolean initMentionedMessageFinish)` |
    `void` | `onPause()` |
    `void` | `stopPlay()` |
    `void` | `onStop()` |
    `void` | `onDestroy()` |
    `boolean` | `filterMessageToHideNewMessageBar(UiMessage uiMessage)` | 过滤只存储不计数消息，使其不显示聊天页面右下角新消息气泡UI.
    `boolean` | `isNormalState()` |
    `boolean` | `isHistoryState()` |
    `void` | `onUserUpdate(UserInfo user)` |
    `void` | `onGroupUpdate(Group group)` |
    `void` | `onGroupUserInfoUpdate(GroupUserInfo groupUserInfo)` |
    `void` | `initTranslationListener()` |
    `void` | `unInitTranslationListener()` |
    `void` | `onTranslationResult(int code, RCTranslationResultWrapper result)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MessageViewModel

          MessageViewModel(Application application)

  - ### Method Detail

    - #### bindConversation

           void bindConversation(ConversationIdentifier conversationIdentifier, Bundle bundle)

    - #### onGetHistoryMessage

           void onGetHistoryMessage(List<Message> messages, boolean isHasMoreMsg)

      初始化加载本地消息 下拉加载历史消息

    - #### onGetHistoryMessage

           void onGetHistoryMessage(List<Message> messages)

      初始化加载本地消息 下拉加载历史消息

    - #### mapUIMessage

           UiMessage mapUIMessage(Message message)

    - #### processHistoryDividerMessage

           void processHistoryDividerMessage()

    - #### refreshAllMessage

           void refreshAllMessage()

    - #### getFirstUnreadMessage

           Message getFirstUnreadMessage()

    - #### setFirstUnreadMessage

           void setFirstUnreadMessage(Message firstUnreadMessage)

    - #### findPositionByMessageId

           int findPositionByMessageId(int messageId)

    - #### getCurTargetId

           String getCurTargetId()

    - #### getCurConversationType

           ConversationType getCurConversationType()

    - #### getConversationIdentifier

           ConversationIdentifier getConversationIdentifier()

    - #### refreshAllMessage

           void refreshAllMessage(boolean force)

    - #### onLoadMoreMessage

           void onLoadMoreMessage(List<Message> messages)

      上拉加载更多消息

    - #### onReloadMessage

           void onReloadMessage(List<Message> messages)

      normal状态点击历史消息bar history状态点击新消息bar

    - #### getPageEventLiveData

           MediatorLiveData<PageEvent> getPageEventLiveData()

    - #### onWarnClick

           void onWarnClick(UiMessage uiMessage)

    - #### onItemClick

           void onItemClick(UiMessage uiMessage)

    - #### onItemLongClick

           boolean onItemLongClick(UiMessage uiMessage)

    - #### onUserPortraitClick

           void onUserPortraitClick(Context context, ConversationType conversationType, UserInfo userInfo, String targetId)

    - #### onUserPortraitLongClick

           boolean onUserPortraitLongClick(Context context, ConversationType conversationType, UserInfo userInfo, String targetId)

    - #### reSendMessage

           void reSendMessage(Message message)

    - #### onAudioClick

           void onAudioClick(UiMessage uiMessage)

    - #### onBackPressed

           boolean onBackPressed()

    - #### quitEditMode

           void quitEditMode()

      退出编辑模式

    - #### findUIMessage

           UiMessage findUIMessage(String messageUId)

    - #### onSendMessage

           void onSendMessage(SendEvent event)

    - #### onSendMediaMessage

           void onSendMediaMessage(SendMediaEvent event)

    - #### onDownloadMessage

           void onDownloadMessage(DownloadEvent event)

    - #### onDeleteMessage

           void onDeleteMessage(DeleteEvent event)

    - #### onRecallEvent

           void onRecallEvent(RecallEvent event)

    - #### onRefreshEvent

           void onRefreshEvent(RefreshEvent event)

    - #### onInsertMessage

           void onInsertMessage(InsertEvent event)

    - #### onClearMessages

           void onClearMessages(ClearEvent event)

    - #### findUIMessage

           UiMessage findUIMessage(int messageId)

    - #### removeUIMessage

           void removeUIMessage(int messageId)

    - #### refreshSingleMessage

           void refreshSingleMessage(UiMessage uiMessage)

    - #### findPositionBySendTime

           int findPositionBySendTime(long sentTime)

    - #### executePageEvent

           void executePageEvent(PageEvent pageEvent)

    - #### processNewMessageUnread

           void processNewMessageUnread(boolean isMainThread)

    - #### updateNewMentionMessageUnreadBar

           void updateNewMentionMessageUnreadBar()

    - #### hideHistoryBar

           void hideHistoryBar()

    - #### getRefreshMessageId

           int getRefreshMessageId()

    - #### getRefreshSentTime

           long getRefreshSentTime()

    - #### getLoadMoreSentTime

           long getLoadMoreSentTime()

    - #### isRemoteMessageLoadFinish

           boolean isRemoteMessageLoadFinish()

    - #### setRemoteMessageLoadFinish

           void setRemoteMessageLoadFinish(boolean remoteMessageLoadFinish)

    - #### isScrollToBottom

           boolean isScrollToBottom()

    - #### setScrollToBottom

           void setScrollToBottom(boolean scrollToBottom)

    - #### updateMentionMessage

           void updateMentionMessage(Message message)

    - #### executePostPageEvent

           void executePostPageEvent(PageEvent pageEvent)

      异步线程切换到主线程执行

      Parameters:
        `pageEvent` - 执行的 event

    - #### onReadReceiptRequestClick

           void onReadReceiptRequestClick(UiMessage uiMessage)

    - #### onReadReceiptStateClick

           void onReadReceiptStateClick(UiMessage uiMessage)

    - #### onReEditClick

           void onReEditClick(UiMessage uiMessage)

    - #### onRefresh

           void onRefresh()

    - #### cleanUnreadNewCount

           void cleanUnreadNewCount()

    - #### addUnreadNewMessage

           void addUnreadNewMessage(UiMessage message)

    - #### newMessageBarClick

           void newMessageBarClick()

    - #### unreadBarClick

           void unreadBarClick()

    - #### newMentionMessageBarClick

           void newMentionMessageBarClick()

    - #### enterEditState

           void enterEditState()

      启动编辑模式

    - #### forwardMessage

           void forwardMessage(Intent data)

    - #### getSelectedUiMessages

           List<UiMessage> getSelectedUiMessages()

    - #### onLoadMore

           void onLoadMore()

    - #### isForegroundActivity

           boolean isForegroundActivity()

    - #### onViewClick

           void onViewClick(int clickType, UiMessage data)

    - #### onViewLongClick

           boolean onViewLongClick(int clickType, UiMessage data)

    - #### getUiMessageLiveData

           LiveData<List<UiMessage>> getUiMessageLiveData()

    - #### getNewMessageUnreadLiveData

           MediatorLiveData<Integer> getNewMessageUnreadLiveData()

    - #### IsEditStatusLiveData

           MediatorLiveData<Boolean> IsEditStatusLiveData()

    - #### getNewUnReadMessages

           List<UiMessage> getNewUnReadMessages()

    - #### getNewUnReadMentionMessages

           List<Message> getNewUnReadMentionMessages()

    - #### setNewUnReadMentionMessages

           void setNewUnReadMentionMessages(List<Message> newUnReadMentionMessages)

    - #### showHistoryBar

           void showHistoryBar(int unreadMessageCount)

    - #### getHistoryMessageUnreadLiveData

           LiveData<Integer> getHistoryMessageUnreadLiveData()

    - #### showNewMentionMessageBar

           void showNewMentionMessageBar(int unreadMessageCount)

    - #### hideNewMentionMessageBar

           void hideNewMentionMessageBar()

    - #### getNewMentionMessageUnreadLiveData

           LiveData<Integer> getNewMentionMessageUnreadLiveData()

    - #### onScrolled

           void onScrolled(RecyclerView recyclerView, int dx, int dy, int headerCount, int footerCount)

    - #### getUiMessages

           List<UiMessage> getUiMessages()

    - #### onExistUnreadMessage

           void onExistUnreadMessage(Conversation conversation, int unreadMessageCount)

    - #### onResume

           void onResume()

    - #### cleanUnreadStatus

           void cleanUnreadStatus()

      清理未读状态

    - #### isInitUnreadMessageFinish

           boolean isInitUnreadMessageFinish()

    - #### setInitUnreadMessageFinish

           void setInitUnreadMessageFinish(boolean initUnreadMessageFinish)

    - #### isInitMentionedMessageFinish

           boolean isInitMentionedMessageFinish()

    - #### setInitMentionedMessageFinish

           void setInitMentionedMessageFinish(boolean initMentionedMessageFinish)

    - #### onPause

           void onPause()

    - #### stopPlay

           void stopPlay()

    - #### onStop

           void onStop()

    - #### onDestroy

           void onDestroy()

    - #### filterMessageToHideNewMessageBar

           boolean filterMessageToHideNewMessageBar(UiMessage uiMessage)

      过滤只存储不计数消息，使其不显示聊天页面右下角新消息气泡UI.

    - #### isNormalState

           boolean isNormalState()

    - #### isHistoryState

           boolean isHistoryState()

    - #### onUserUpdate

           void onUserUpdate(UserInfo user)

    - #### onGroupUpdate

           void onGroupUpdate(Group group)

    - #### onGroupUserInfoUpdate

           void onGroupUserInfoUpdate(GroupUserInfo groupUserInfo)

    - #### initTranslationListener

           void initTranslationListener()

    - #### unInitTranslationListener

           void unInitTranslationListener()

    - #### onTranslationResult

           void onTranslationResult(int code, RCTranslationResultWrapper result)