Exemplo n.º 1
0
        public void SetListViewHeightBasedOnChildren(ListView listView)
        {
            GoHejaEventAdapter listAdapter = listView.Adapter as GoHejaEventAdapter;

            if (listAdapter == null)
            {
                return;
            }

            int totalHeight  = 0;
            int desiredWidth = View.MeasureSpec.MakeMeasureSpec(listView.Width, MeasureSpecMode.AtMost);

            for (int i = 0; i < listAdapter.Count; i++)
            {
                View listItem   = listAdapter.GetView(i, null, listView);
                int  heightSpec = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
                listItem.Measure(desiredWidth, heightSpec);
                totalHeight += listItem.MeasuredHeight;
            }

            ViewGroup.LayoutParams lp = listView.LayoutParameters;
            lp.Height = totalHeight + (listView.DividerHeight * (listAdapter.Count - 1));
            listView.LayoutParameters = lp;
            listView.RequestLayout();
        }
Exemplo n.º 2
0
        void FilterEventsByDate(DateTime filterDate)
        {
            List <GoHejaEvent> filteredEvents = new List <GoHejaEvent>();

            if (_events != null && _events.Count != 0)
            {
                for (int i = 0; i < _events.Count; i++)
                {
                    var startDate = _events[i].StartDateTime();
                    if (startDate.DayOfYear == filterDate.DayOfYear)
                    {
                        filteredEvents.Add(_events[i]);
                    }
                }
            }
            if (DateTime.Compare(filterDate, DateTime.Now) > 0)
            {
                SetPerformanceDataColor(true);
            }
            else
            {
                SetPerformanceDataColor(false);
            }

            if (filteredEvents.Count == 0)
            {
                noEventsContent.Visibility = ViewStates.Visible;
            }
            else
            {
                noEventsContent.Visibility = ViewStates.Gone;
            }

            eventsList = FindViewById(Resource.Id.eventsList) as ListView;
            var adapter = new GoHejaEventAdapter(filteredEvents, this);

            eventsList.Adapter = adapter;
            adapter.NotifyDataSetChanged();
            SetListViewHeightBasedOnChildren(eventsList);

            InitPerformanceData(filterDate);
        }