public void LoadLocalLatestMessages()
        {
            try
            {
                loadList = false;

                if (chatConversation != null)
                {
                    ListChatsCon = ChatMessageRepository.GetChatMessagesForPageIndex(paginationModel, chatConversation.ChatId);

                    if (ListChatsCon != null && ListChatsCon.Count > 0)
                    {
                        tblChat.TableFooterView = new UIView();

                        chatViewContarollerSource = new ChatViewContarollerSource(ListChatsCon, this);

                        tblChat.Source    = chatViewContarollerSource;
                        tblChat.RowHeight = 40;
                        tblChat.ReloadData();
                        ScrollToBottom(true);
                    }
                }
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
 public void LoadLocalPreviousMessages()
 {
     try
     {
         loadList = false;
         paginationModel.SkipRecords += 30;
         if (chatConversation != null)
         {
             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)
             {
                 mAdapter = new PrivateMessgeAdapter(this, ListChatsCon);
                 mRecyclerView.SetAdapter(mAdapter);
                 mAdapter.NotifyDataSetChanged();
                 mRecyclerView.ScrollToPosition(CurrentListCount - PreviousListCount - 2);
                 loadList = true;
             }
         }
     }
     catch (Exception e)
     {
         Crashes.TrackError(e);
     }
 }
        public void LoadLocalLatestMessages()
        {
            try
            {
                loadList = false;

                if (chatConversation != null)
                {
                    ListChatsCon = ChatMessageRepository.GetChatMessagesForPageIndex(paginationModel, chatConversation.ChatId);

                    if (ListChatsCon != null && ListChatsCon.Count > 0)
                    {
                        mAdapter = new PrivateMessgeAdapter(this, ListChatsCon);
                        mRecyclerView.SetAdapter(mAdapter);
                        mAdapter.NotifyDataSetChanged();
                        mRecyclerView.ScrollToPosition(mAdapter.ItemCount - 1);
                        loadList = true;
                    }
                }
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
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);
            }
        }
        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);
            }
        }