private static string GetDisplayMemberNames(List <MessagingChannel.Member> members) { if (members.Count < 2) { return("No Members"); } else if (members.Count == 2) { StringBuilder names = new StringBuilder(); foreach (var member in members) { if (member.GetId().Equals(SendBirdSDK.GetUserId())) { continue; } names.Append(", " + member.name); } return(names.Remove(0, 2).ToString()); } else { return("Group " + members.Count); } }
private static string GetDisplayCoverImageUrl(List <MessagingChannel.Member> members) { foreach (MessagingChannel.Member member in members) { if (member.id.Equals(SendBirdSDK.GetUserId())) { continue; } return(member.imageUrl); } return(string.Empty); }
public void SetTypeStatus(string userId, long timestamp) { if (userId.Equals(SendBirdSDK.GetUserId())) { return; } if (timestamp <= 0) { mTypeStatus.Remove(userId); } else { mTypeStatus[userId] = timestamp; } }
public override View GetView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder = null; Object item = this [position]; if (convertView == null || (convertView.Tag as ViewHolder).GetViewType() != GetItemViewType(position)) { viewHolder = new ViewHolder(); viewHolder.SetViewType(GetItemViewType(position)); switch (GetItemViewType(position)) { case TYPE_UNSUPPORTED: { convertView = new View(mInflater.Context); convertView.Tag = viewHolder; break; } case TYPE_MESSAGE: { TextView tv; ImageView iv; View v; convertView = mInflater.Inflate(Resource.Layout.SendBirdViewMessagingMessage, parent, false); v = convertView.FindViewById(Resource.Id.left_container); viewHolder.SetView("left_container", v); iv = convertView.FindViewById(Resource.Id.img_left_thumbnail) as ImageView; viewHolder.SetView("left_thumbnail", iv); tv = convertView.FindViewById(Resource.Id.txt_left) as TextView; viewHolder.SetView("left_message", tv); tv = convertView.FindViewById(Resource.Id.txt_left_name) as TextView; viewHolder.SetView("left_name", tv); tv = convertView.FindViewById(Resource.Id.txt_left_time) as TextView; viewHolder.SetView("left_time", tv); v = convertView.FindViewById(Resource.Id.right_container); viewHolder.SetView("right_container", v); iv = convertView.FindViewById(Resource.Id.img_right_thumbnail) as ImageView; viewHolder.SetView("right_thumbnail", iv); tv = convertView.FindViewById(Resource.Id.txt_right) as TextView; viewHolder.SetView("right_message", tv); tv = convertView.FindViewById(Resource.Id.txt_right_name) as TextView; viewHolder.SetView("right_name", tv); tv = convertView.FindViewById(Resource.Id.txt_right_time) as TextView; viewHolder.SetView("right_time", tv); tv = convertView.FindViewById(Resource.Id.txt_right_status) as TextView; viewHolder.SetView("right_status", tv); convertView.Tag = viewHolder; break; } case TYPE_SYSTEM_MESSAGE: { convertView = mInflater.Inflate(Resource.Layout.SendBirdViewSystemMessage, parent, false); viewHolder.SetView("message", convertView.FindViewById(Resource.Id.txt_message) as TextView); convertView.Tag = viewHolder; break; } case TYPE_BROADCAST_MESSAGE: { convertView = mInflater.Inflate(Resource.Layout.SendBirdViewSystemMessage, parent, false); viewHolder.SetView("message", convertView.FindViewById(Resource.Id.txt_message) as TextView); convertView.Tag = viewHolder; break; } case TYPE_TYPING_INDICATOR: { convertView = mInflater.Inflate(Resource.Layout.SendBirdViewTypingIndicator, parent, false); viewHolder.SetView("message", convertView.FindViewById(Resource.Id.txt_message)); convertView.Tag = viewHolder; break; } } } viewHolder = convertView.Tag as ViewHolder; switch (GetItemViewType(position)) { case TYPE_UNSUPPORTED: break; case TYPE_MESSAGE: { SendBird.Model.Message message = item as SendBird.Model.Message; if (message.GetSenderId().Equals(SendBirdSDK.GetUserId())) { viewHolder.GetView("left_container").Visibility = ViewStates.Gone; viewHolder.GetView("right_container").Visibility = ViewStates.Visible; // DisplayUrlImage() viewHolder.GetView <TextView> ("right_name").Text = message.GetSenderName(); viewHolder.GetView <TextView> ("right_message").Text = message.message; viewHolder.GetView <TextView> ("right_time").Text = GetDisplayDateTime(mContext, message.messageTimestamp); int readCount = 0; foreach (string key in mReadStatus.Keys) { if (key.Equals(message.GetSenderId())) { readCount += 1; continue; } if (mReadStatus [key] >= message.messageTimestamp) { readCount += 1; } } if (readCount < mReadStatus.Count) { if (mReadStatus.Count - readCount > 1) { viewHolder.GetView <TextView> ("right_status").Text = "Unread " + (mReadStatus.Count - readCount); } else { viewHolder.GetView <TextView> ("right_status").Text = "Unread"; } } else { viewHolder.GetView <TextView> ("right_status").Text = string.Empty; } } else { viewHolder.GetView("left_container").Visibility = ViewStates.Visible; viewHolder.GetView("right_container").Visibility = ViewStates.Gone; // DisplayUrlImage() viewHolder.GetView <TextView> ("left_name").Text = message.GetSenderName(); viewHolder.GetView <TextView> ("left_message").Text = message.message; viewHolder.GetView <TextView> ("left_time").Text = GetDisplayDateTime(mContext, message.messageTimestamp); } break; } case TYPE_SYSTEM_MESSAGE: { SendBird.Model.SystemMessage systemMessage = item as SendBird.Model.SystemMessage; viewHolder.GetView <TextView> ("message").TextFormatted = Html.FromHtml(systemMessage.message); break; } case TYPE_BROADCAST_MESSAGE: { SendBird.Model.BroadcastMessage broadcastMessage = item as SendBird.Model.BroadcastMessage; viewHolder.GetView <TextView> ("message").TextFormatted = Html.FromHtml(broadcastMessage.message); break; } case TYPE_TYPING_INDICATOR: { System.Collections.ICollection itemList = (System.Collections.ICollection)item; int itemCount = itemList.Count; string typeMsg = (item as List <string>)[0] + ((itemCount > 1) ? " +" + (itemCount - 1) : "") + ((itemCount > 1) ? " are " : " is ") + "typing..."; viewHolder.GetView <TextView> ("message").Text = typeMsg; break; } } return(convertView); }
private void InitUIComponents() { mTopBarContainer = FindViewById(Resource.Id.top_bar_container); mTxtChannelUrl = FindViewById(Resource.Id.txt_channel_url) as TextView; mSettingsContainer = FindViewById(Resource.Id.settings_container); mSettingsContainer.Visibility = ViewStates.Gone; mBtnClose = FindViewById(Resource.Id.btn_close) as ImageButton; mBtnClose.Click += (object sender, EventArgs e) => { Finish(); }; mBtnInvite = FindViewById(Resource.Id.btn_invite) as Button; mBtnInvite.Click += (sender, e) => { var intent = new Intent(this, typeof(SendBirdMemberListActivity)); Bundle args = null; args = SendBirdMemberListActivity.MakeSendBirdArgs(SendBirdSDK.GetAppId(), SendBirdSDK.GetUserId(), SendBirdSDK.GetUserName()); intent.PutExtras(args); StartActivityForResult(intent, REQUEST_MEMBER_LIST); mSettingsContainer.Visibility = ViewStates.Gone; }; mBtnSettings = FindViewById(Resource.Id.btn_settings) as ImageButton; mBtnSettings.Click += (sender, e) => { if (mSettingsContainer.Visibility != ViewStates.Visible) { mSettingsContainer.Visibility = ViewStates.Visible; } else { mSettingsContainer.Visibility = ViewStates.Gone; } }; ResizeMenubar(); }