Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
        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);
            }
        }