Example #1
0
        public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
        {
            ListItem msg = messages[indexPath.Row];

            if (msg.getType() == 1)
            {
                List <ChatAttachment> AttachList = new List <ChatAttachment>();

                GeneralItem GeneralItem = (GeneralItem)msg;

                var item = GeneralItem.getChatMessagearray();
                AttachList = (item.ChatMessageId != 0) ? Repositories.ChatAttachmentRepository.GetChatAttachList(item.ChatMessageId) : new List <ChatAttachment>();
                if (AttachList.Count > 0)
                {
                    return(ChatBubbleWithAttachmentCell.GetHeight(tableView, item.MessageText, "10:11 PM").Height);
                }
                else
                {
                    return(ChatBubbleCell.GetHeight(tableView, item.MessageText, "10:11 PM").Height);
                }
            }
            else
            {
                return(32);
            }// return ChatBubbleCell.GetSizeForText(tableView, messages[indexPath.Row].Text).Height + ChatBubbleCell.BubblePadding.Height;
             //Message msg = messages[indexPath.Row];
             //return CalculateHeightFor(msg, tableView);
        }
Example #2
0
        public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
        {
            ListItem msg = messages[indexPath.Row];

            if (msg.getType() == 1)
            {
                List <GroupAttachment> AttachList = new List <GroupAttachment>();

                GeneralGroupItem GeneralItem = (GeneralGroupItem)msg;
                var item = GeneralItem.getChatMessagearray();

                AttachList = (item.MessageId != 0) ? Repositories.GroupRepository.GetGroupMessageAttachList(item.MessageId) : new List <GroupAttachment>();
                Boolean isMe = item.SenderUserId == Common.CommonHelper.GetUserId();
                if (!isMe)
                {
                    if (AttachList.Count > 0)
                    {
                        return(GroupChatBubbleWithAttachmentCell.GetHeight(tableView, item.MessageText, "10:11 PM").Height);
                    }
                    else
                    {
                        return(GroupChatBubbleCell.GetHeight(tableView, item.MessageText, "10:11 PM").Height);
                    }
                }
                else
                {
                    if (AttachList.Count > 0)
                    {
                        return(ChatBubbleWithAttachmentCell.GetHeight(tableView, item.MessageText, "10:11 PM").Height);
                    }
                    else
                    {
                        return(ChatBubbleCell.GetHeight(tableView, item.MessageText, "10:11 PM").Height);
                    }
                }
            }
            else
            {
                return(32);
            }
        }
Example #3
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            //BubbleCell cell = null;
            //Message msg = messages[indexPath.Row];

            //cell = (BubbleCell)tableView.DequeueReusableCell(GetReuseId(msg.Type));
            //cell.Message = msg;

            //return cell;
            bool     isLeft = false;
            ListItem msg    = messages[indexPath.Row];
            List <ChatAttachment> AttachList = new List <ChatAttachment>();
            ChatMessage           item       = new ChatMessage();

            switch (msg.getType())
            {
            case 0:
            {
                //DateViewHolder dh = holder as DateViewHolder;
                DateItem DateItem = (DateItem)msg;

                var cell = tableView.DequeueReusableCell("DateLabelCell") as DateLabelCell;
                cell.UpdateCell(DateItem);

                return(cell);
            }

            default:

                GeneralItem GeneralItem = (GeneralItem)msg;
                item = GeneralItem.getChatMessagearray();

                Boolean isMe = item.ContactId != Common.CommonHelper.GetUserId();
                AttachList = (item.ChatMessageId != 0) ? Repositories.ChatAttachmentRepository.GetChatAttachList(item.ChatMessageId) : new List <ChatAttachment>();

                if (isMe)
                {
                    isLeft = false;
                }
                else
                {
                    isLeft = true;
                }

                if (AttachList.Count > 0)
                {
                    var cell = tableView.DequeueReusableCell("PrivateChatAttachmentCell") as PrivateChatAttachmentCell;
                    cell.Update(item, this.uiNewView, isLeft);
                    cell.OpenImageViewEvent += Cell_OpenImageViewEvent;
                    //  var cell = tableView.DequeueReusableCell(isLeft ? PrivateChatAttachmentCell.KeyLeft : PrivateChatAttachmentCell.KeyRight) as PrivateChatAttachmentCell;
                    //if (cell == null)
                    //cell = new PrivateChatAttachmentCell(isLeft);
                    //cell.Update(item);

                    return(cell);
                }
                else
                {
                    var cell = tableView.DequeueReusableCell(isLeft ? ChatBubbleCell.KeyLeft : ChatBubbleCell.KeyRight) as ChatBubbleCell;
                    if (cell == null)
                    {
                        cell = new ChatBubbleCell(isLeft);
                    }
                    cell.Update(item);
                    return(cell);
                }
            }
        }