private void InitUIAndData() { InitCallbackAndListener(); _chatManager = MainApplication.ChatManager; _chatManager.RegisterListener(_myRtmClientListener); _titleTextView = FindViewById <TextView>(Resource.Id.message_title); _msgEditText = FindViewById <EditText>(Resource.Id.message_edittiext); _recyclerView = FindViewById <RecyclerView>(Resource.Id.message_list); _btnSend = FindViewById <TextView>(Resource.Id.selection_chat_btn); _btnImageSend = FindViewById <ImageView>(Resource.Id.selection_img_btn); _btnBack = FindViewById <ImageView>(Resource.Id.back); _btnBack.Click += OnClickFinish; _btnSend.Click += OnClickTextSend; _btnImageSend.Click += OnClickImageSend; _isPeerToPeerMode = Intent.GetBooleanExtra(MessageUtil.IntentExtraIsPeerMode, true); _userId = Intent.GetStringExtra(MessageUtil.IntentExtraUserId); string targetName = Intent.GetStringExtra(MessageUtil.IntentExtraTargetName); if (_isPeerToPeerMode) { _peerId = targetName; _titleTextView.Text = _peerId; MessageListBean messageListBean = MessageUtil.GetExistMessageListBean(_peerId); if (messageListBean != null) { _messageBeanList.AddRange(messageListBean.MessageBeanList); } MessageListBean offlineMessageBean = new MessageListBean(_peerId, _chatManager); _messageBeanList.AddRange(offlineMessageBean.MessageBeanList); _chatManager.RemoveAllOfflineMessages(_peerId); _titleTextView.Text = $"Chat with {_peerId}"; } else { _channelName = targetName; _channelMemberCount = 1; _titleTextView.Text = $"{_channelName}({_channelMemberCount})"; } LinearLayoutManager layoutManager = new LinearLayoutManager(this); _recyclerView.SetLayoutManager(layoutManager); layoutManager.Orientation = OrientationHelper.Vertical; _messageAdapter = new MessageAdapter(this, _messageBeanList); _recyclerView.SetAdapter(_messageAdapter); }
public static void AddMessageBean(string account, RtmMessage msg) { MessageBean messageBean = new MessageBean(account, msg, false); int ret = ExistMessageListBean(account); if (ret == -1) { // account not exist new messagelistbean messageBean.Background = ColorList[RandomGenerator.NextInt(ColorList.Count)]; List <MessageBean> messageBeanList = new List <MessageBean> { messageBean }; _messageListBeanList.Add(new MessageListBean(account, messageBeanList)); } else { // account exist get messagelistbean MessageListBean bean = _messageListBeanList[ret]; List <MessageBean> messageBeanList = bean.MessageBeanList; if (messageBeanList.Count > 0) { messageBean.Background = messageBeanList[0].Background; } else { messageBean.Background = ColorList[RandomGenerator.NextInt(ColorList.Count)]; } messageBeanList.Add(messageBean); bean.MessageBeanList = messageBeanList; } }
public static void AddMessageListBeanList(MessageListBean messageListBean) { _messageListBeanList.Add(messageListBean); }