Exemplo n.º 1
0
        public void LoadLocalPreviousMessages()
        {
            try
            {
                loadList = false;
                paginationModel.SkipRecords += 30;

                int PreviousListCount = ListChatsCon.Values.Sum(list => list.Count);
                ListChatsCon = GroupRepository.GetGroupMessagesForPageIndex(paginationModel, GroupObject.GroupId);
                int CurrentListCount = ListChatsCon.Values.Sum(list => list.Count);
                if (ListChatsCon != null && ListChatsCon.Count > 0)
                {
                    //mAdapter = new GroupMessageAdapter(this, ListChatsCon);
                    //mRecyclerView.SetAdapter(mAdapter);
                    //mAdapter.NotifyDataSetChanged();
                }
                if (ListChatsCon != null && ListChatsCon.Count > 0)
                {
                    consolidatedList = new List <ListItem>();

                    foreach (var itemm in ListChatsCon)
                    {
                        DateItem dateItem = new DateItem();
                        dateItem.setDate(itemm.Key.ToShortDateString());
                        consolidatedList.Add(dateItem);

                        foreach (var general in itemm.Value)
                        {
                            GeneralGroupItem generalItem = new GeneralGroupItem();
                            generalItem.setChatMessagearray(general);
                            consolidatedList.Add(generalItem);
                        }
                    }


                    chatSource         = new GroupChatListSource(consolidatedList, this);
                    tblChatList.Source = chatSource;

                    tblChatList.ReloadData();
                    tblChatList.ScrollToNearestSelected(UITableViewScrollPosition.Middle, true);
                    loadList = true;
                }
            }
            catch (Exception e)
            {
                //  Crashes.TrackError(e);
            }
        }
Exemplo n.º 2
0
        public async void LoadLocalLatestMessages()
        {
            try
            {
                loadList = false;

                if (GroupObject != null)
                {
                    ListChatsCon = GroupRepository.GetGroupMessagesForPageIndex(paginationModel, GroupObject.GroupId);

                    if (ListChatsCon != null && ListChatsCon.Count > 0)
                    {
                        consolidatedList = new List <ListItem>();

                        foreach (var itemm in ListChatsCon)
                        {
                            DateItem dateItem = new DateItem();
                            dateItem.setDate(itemm.Key.ToShortDateString());
                            consolidatedList.Add(dateItem);

                            foreach (var general in itemm.Value)
                            {
                                GeneralGroupItem generalItem = new GeneralGroupItem();
                                generalItem.setChatMessagearray(general);
                                consolidatedList.Add(generalItem);
                            }
                        }


                        chatSource         = new GroupChatListSource(consolidatedList, this);
                        tblChatList.Source = chatSource;


                        tblChatList.Add(RefreshControl);
                        tblChatList.ReloadData();
                        ScrollToBottom(true);
                    }
                }
            }
            catch (Exception e)
            {
                //Crashes.TrackError(e);
            }
        }
Exemplo n.º 3
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);
            }
        }
        public void LoadLocalLatestMessages()
        {
            try
            {
                loadList = false;

                if (contactViewModel != null)
                {
                    ListChatsCon = GroupRepository.GetGroupMessagesForPageIndex(paginationModel, Convert.ToInt32(contactViewModel.GroupId));
                    messages     = new List <Message>();
                    if (ListChatsCon != null && ListChatsCon.Count > 0)
                    {
                        consolidatedList = new List <ListItem>();

                        foreach (var itemm in ListChatsCon)
                        {
                            DateItem dateItem = new DateItem();
                            dateItem.setDate(itemm.Key.ToShortDateString());
                            consolidatedList.Add(dateItem);

                            foreach (var general in itemm.Value)
                            {
                                GeneralGroupItem generalItem = new GeneralGroupItem();
                                generalItem.setChatMessagearray(general);
                                consolidatedList.Add(generalItem);
                            }
                        }



                        foreach (var ChatConverstions in consolidatedList)
                        {
                            message = new Message();
                            switch (ChatConverstions.getType())
                            {
                            case 1:
                            {
                                GeneralGroupItem GeneralItem = (GeneralGroupItem)ChatConverstions;
                                var     item       = GeneralItem.getChatMessagearray();
                                Boolean isMe       = item.SenderUserId == Common.CommonHelper.GetUserId();
                                var     AttachList = (item.MessageId != 0) ? Repositories.GroupRepository.GetGroupMessageAttachList(item.MessageId) : new List <GroupAttachment>();

                                if (isMe)
                                {
                                    message.Text = item.MessageText;
                                    message.Type = MessageType.Outgoing;
                                }

                                else
                                {
                                    message.Text = message.Text = item.senderName + "\n" + item.MessageText;
                                    message.Type = MessageType.Incoming;
                                }

                                break;
                            }

                            case 0:
                            {
                                break;
                            }
                            }

                            messages.Add(message);
                        }

                        chatSource       = new ChatSource(messages);
                        tableView.Source = chatSource;
                        tableView.ReloadData();
                        ScrollToBottom(true);
                    }
                }
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
Exemplo n.º 5
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 <GroupAttachment> AttachList = new List <GroupAttachment>();
            GroupMessage           item       = new GroupMessage();

            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:
                GeneralGroupItem GeneralItem = (GeneralGroupItem)msg;
                item = GeneralItem.getChatMessagearray();

                Boolean isMe = item.SenderUserId == Common.CommonHelper.GetUserId();
                AttachList = (item.MessageId != 0) ? Repositories.GroupRepository.GetGroupMessageAttachList(item.MessageId) : new List <GroupAttachment>();

                if (isMe)
                {
                    isLeft = false;

                    if (AttachList.Count > 0)
                    {
                        //var cell = tableView.DequeueReusableCell(isLeft ? ChatBubbleWithAttachmentCell.KeyLeft : ChatBubbleWithAttachmentCell.KeyRight) as ChatBubbleWithAttachmentCell;
                        //if (cell == null)
                        //cell = new ChatBubbleWithAttachmentCell(isLeft);
                        var cell = tableView.DequeueReusableCell("PrivateChatAttachmentCell") as PrivateChatAttachmentCell;
                        cell.UpdateGroup(item, this.uiNewView, isLeft);
                        //   cell.UpdateGroup(item);
                        return(cell);
                    }
                    else
                    {
                        var cell = tableView.DequeueReusableCell(isLeft ? ChatBubbleCell.KeyLeft : ChatBubbleCell.KeyRight) as ChatBubbleCell;
                        if (cell == null)
                        {
                            cell = new ChatBubbleCell(isLeft);
                        }
                        cell.UpdateGroup(item);
                        return(cell);
                    }
                }
                else
                {
                    isLeft = true;
                    if (AttachList.Count > 0)
                    {
                        //var cell = tableView.DequeueReusableCell(isLeft ? GroupChatBubbleWithAttachmentCell.KeyLeft : GroupChatBubbleWithAttachmentCell.KeyRight) as GroupChatBubbleWithAttachmentCell;
                        //if (cell == null)
                        //cell = new GroupChatBubbleWithAttachmentCell(isLeft);

                        var cell = tableView.DequeueReusableCell("GroupChatAttachmentCell") as GroupChatAttachmentCell;
                        cell.Update(item, this.uiNewView, isLeft);
                        // cell.Update(item);
                        return(cell);
                    }
                    else
                    {
                        var cell = tableView.DequeueReusableCell(isLeft ? GroupChatBubbleCell.KeyLeft : GroupChatBubbleCell.KeyRight) as GroupChatBubbleCell;
                        if (cell == null)
                        {
                            cell = new GroupChatBubbleCell(isLeft);
                        }
                        cell.Update(item);
                        return(cell);
                    }
                }
            }
        }