Beispiel #1
0
        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);
        }