Beispiel #1
0
 public void UpdateCellData(NotificationItemModel item)
 {
     NotificationText.Text = item.Message;
     AreaImage.Image       = item.Icon;
 }
        private void RefreshTable(List <NotificationModel> notificationList)
        {
            var Headers = new List <AreaModel>();

            foreach (var item in notificationList)
            {
                if (String.IsNullOrEmpty(item.AreaGUID))
                {
                    item.AreaGUID = DefaultAreaName;//SL.AreaGUID;

                    if (!Headers.Exists((x) => x.areaGUID == DefaultAreaName))
                    {
                        Headers.Insert(0, new AreaModel()
                        {
                            areaName = DefaultAreaName, areaGUID = DefaultAreaName
                        });
                    }

                    continue;
                }

                var area = SL.AreaList?.Find((x) => x.areaGUID == item.AreaGUID);
                if (area != null && !Headers.Exists((x) => x.areaGUID == area.areaGUID))
                {
                    Headers.Add(area);
                }
            }

            //create the data
            var list = new List <ExpandableTableModel <NotificationItemModel> >();

            foreach (var section in Headers)
            {
                var filteredNotificationList = notificationList.FindAll((x) =>
                                                                        (string.IsNullOrEmpty(x.AreaGUID) ? DefaultAreaName : x.AreaGUID) == section.areaGUID);

                if (filteredNotificationList == null || filteredNotificationList.Count == 0)
                {
                    continue;
                }

                var sectionData = new ExpandableTableModel <NotificationItemModel>()
                {
                    Title = section.areaName,
                    Icon  = GetImageByUrlOrDefault(section.areaDefaultImageURL, section.areaGUID == DefaultAreaName),
                    NotificationsCount = filteredNotificationList.Count.ToString()
                };

                foreach (var row in filteredNotificationList)
                {
                    var notificationItem = new NotificationItemModel()
                    {
                        Message = row.Message,
                        Icon    = sectionData.Icon,//if no special icon for row
                        Item    = row
                    };
                    sectionData.Add(notificationItem);
                }

                list.Add(sectionData);
            }

            TableView.Source = new NotificationsTableSource <NotificationItemModel>(list, TableView);
        }