示例#1
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            ProgramItemVO pi = ProgramItems[position];

            if (holder is ProgrammDayViewHolder)
            {
                ProgrammDayViewHolder vh = holder as ProgrammDayViewHolder;
                vh.lblDay.Text = pi.Title;
            }
            else
            {
                ProgrammItemViewHolder vh = holder as ProgrammItemViewHolder;
                vh.lblHour.Text = pi.StartTime + ((pi.StartTime != null && pi.EndTime != null) ? " - ":"") + pi.EndTime;
                if (pi.Location != null)
                {
                    vh.lblLocation.Text = pi.Location.Name;
                }
                vh.lblContent.Text = pi.Title;
                if (pi.HasParentProgramItems)
                {
                    vh.vwInset.Visibility = ViewStates.Visible;
                    var lp = vh.lblHour.LayoutParameters as RelativeLayout.LayoutParams;
                    lp.LeftMargin = (int)convertDpToPixel(30, vh.lblHour.Context);
                    vh.lblHour.LayoutParameters = lp;
                }
                else
                {
                    vh.vwInset.Visibility = ViewStates.Gone;
                    var lp = vh.lblHour.LayoutParameters as RelativeLayout.LayoutParams;
                    lp.LeftMargin = (int)convertDpToPixel(20, vh.lblHour.Context);
                    vh.lblHour.LayoutParameters = lp;
                }
            }
        }
示例#2
0
        public List <ProgramItemVO> GetAllProgramItems()
        {
            if (ProgramItems == null)
            {
                List <ProgramItemVO> returnValue = new List <ProgramItemVO>();
                var locations = database.GetAllLocations();
                Locations = new List <LocationVO>();
                foreach (var location in locations)
                {
                    LocationVO loc = new LocationVO(location);
                    Locations.Add(loc);
                }
                var progItems = database.GetAllProgramItems();
                ProgramItems = new List <ProgramItemVO>();
                foreach (var progItem in progItems)
                {
                    ProgramItemVO programmaItem = new ProgramItemVO(progItem.ParentID, progItem.ID, progItem.Title, progItem.StartTime, progItem.EndTime);
                    if (progItem.Location != null)
                    {
                        programmaItem.Location = Locations.Find(x => x.ID == progItem.Location);
                    }
                    var parentItem = ProgramItems.Find(x => x.ID == programmaItem.ParentID);
                    if (parentItem != null)
                    {
                        parentItem.HasChildProgramItems = true;
                        if (parentItem.ChildProgramItems == null)
                        {
                            parentItem.ChildProgramItems = new List <ProgramItemVO>();
                        }
                        parentItem.ChildProgramItems.Add(programmaItem);
                        if (parentItem.ParentID != 0)
                        {
                            programmaItem.HasParentProgramItems = true;
                        }
                        else
                        {
                            programmaItem.HasParentProgramItems = false;
                        }

                        ProgramItems.Insert(ProgramItems.IndexOf(parentItem) + parentItem.ChildProgramItems.Count, programmaItem);
                    }
                    else
                    {
                        ProgramItems.Add(programmaItem);
                    }
                }
            }
            return(ProgramItems);
        }