Пример #1
0
        public void RefreshNewAddedRows(ChatMessageViewModel chatModel, ChatMessage savedMessages)
        {
            DateItem dateItem = new DateItem();

            dateItem.setDate(chatModel.MessageTime.ToShortDateString());
            var  listofDates = consolidatedList.Where(a => a.getType() == 0).ToList();
            bool dateExist   = false;

            for (int i = 0; i < listofDates.Count; i++)
            {
                ListItem msg      = listofDates[i];
                DateItem DateItem = (DateItem)msg;
                if (DateItem.getDate() == dateItem.getDate())
                {
                    dateExist = true;
                }
            }
            if (!dateExist)
            {
                consolidatedList.Add(dateItem);
            }

            GeneralItem generalItem = new GeneralItem();

            generalItem.setChatMessagearray(savedMessages);
            consolidatedList.Add(generalItem);
            tblChatList.ReloadData();
            ScrollToBottom(true);
            filePath      = "";
            thumbFilePath = "";
        }
Пример #2
0
        public void LoadLocalPreviousMessages()
        {
            try
            {
                loadList = false;
                paginationModel.SkipRecords += 30;

                int PreviousListCount = ListChatsCon.Values.Sum(list => list.Count);
                ListChatsCon = ChatMessageRepository.GetChatMessagesForPageIndex(paginationModel, chatConversation.ChatId);
                int CurrentListCount = ListChatsCon.Values.Sum(list => list.Count);

                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)
                        {
                            GeneralItem generalItem = new GeneralItem();
                            generalItem.setChatMessagearray(general);
                            consolidatedList.Add(generalItem);
                        }
                    }


                    chatSource                     = new ChatListSource(consolidatedList, this);
                    tblChatList.Source             = chatSource;
                    chatSource.OpenImageViewEvent += ChatSource_EventHandler;
                    tblChatList.ReloadData();
                    ScrollToBottom(true);
                }
            }
            catch (Exception e)
            {
                //  Crashes.TrackError(e);
            }
        }
Пример #3
0
        public void LoadLocalLatestMessages()
        {
            try
            {
                loadList = false;
                if (chatConversation != null)
                {
                    consolidatedList = new List <ListItem>();
                    ListChatsCon     = ChatMessageRepository.GetChatMessagesForPageIndex(paginationModel, chatConversation.ChatId);
                    messages         = new List <Message>();
                    if (ListChatsCon != null && ListChatsCon.Count > 0)
                    {
                        foreach (var itemm in ListChatsCon)
                        {
                            DateItem dateItem = new DateItem();
                            dateItem.setDate(itemm.Key.ToShortDateString());
                            consolidatedList.Add(dateItem);
                            foreach (var general in itemm.Value)
                            {
                                GeneralItem generalItem = new GeneralItem();
                                generalItem.setChatMessagearray(general);
                                consolidatedList.Add(generalItem);
                            }
                        }
                        chatSource = new ChatListSource(consolidatedList, this);

                        tblChatList.Source             = chatSource;
                        chatSource.OpenImageViewEvent += ChatSource_OpenImageViewEvent;
                        tblChatList.Add(RefreshControl);

                        tblChatList.ReloadData();

                        ScrollToBottom(true);
                    }
                }
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
Пример #4
0
        public ChatViewContarollerSource(Dictionary <DateTime, List <ChatMessage> > items, UIViewController uiView)
        {
            this.ChatConverstions = items;
            this.uiNewView        = uiView;

            consolidatedList = new List <ListItem>();

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

                foreach (var general in itemm.Value)
                {
                    GeneralItem generalItem = new GeneralItem();
                    generalItem.setChatMessagearray(general);
                    consolidatedList.Add(generalItem);
                }
            }
        }
        public void LoadLocalLatestMessages()
        {
            try
            {
                loadList = false;

                if (chatConversation != null)
                {
                    ListChatsCon = ChatMessageRepository.GetChatMessagesForPageIndex(paginationModel, chatConversation.ChatId);
                    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)
                            {
                                GeneralItem generalItem = new GeneralItem();
                                generalItem.setChatMessagearray(general);
                                consolidatedList.Add(generalItem);
                            }
                        }



                        foreach (var ChatConverstions in consolidatedList)
                        {
                            message = new Message();
                            switch (ChatConverstions.getType())
                            {
                            case 1:
                            {
                                GeneralItem GeneralItem = (GeneralItem)ChatConverstions;
                                var         item        = GeneralItem.getChatMessagearray();
                                Boolean     isMe        = item.ContactId != Common.CommonHelper.GetUserId();
                                var         AttachList  = (item.ChatMessageId != 0) ? Repositories.ChatAttachmentRepository.GetChatAttachList(item.ChatMessageId) : new List <ChatAttachment>();

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

                                else
                                {
                                    message.Text = 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);
            }
        }