Exemplo n.º 1
0
            public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
            {
                var control = new SingleDayControl(parent)
                {
                    LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)
                };

                control.ItemClick         += SingleDayControl_ItemClick;
                control.HolidayItemClick  += SingleDayControl_HolidayItemClick;
                control.ScheduleItemClick += SingleDayControl_ScheduleItemClick;
                control.ScheduleClick     += SingleDayControl_ScheduleClick;

                return(new GenericRecyclerViewHolder(control));
            }
Exemplo n.º 2
0
            public override Java.Lang.Object InstantiateItem(ViewGroup container, int position)
            {
                DateTime date = GetDate(position);

                var homeworksOnDay = HomeworksOnDay.Get(ItemsSource.Items, date);

                SingleDayControl control = _destroyedControls.FirstOrDefault();

                if (control != null)
                {
                    _destroyedControls.Remove(control);

                    try
                    {
                        control.Initialize(date, homeworksOnDay, ItemsSource);
                    }

                    // ObjectDisposedException actually shouldn't ever occur here. If it does, we should analyze why.
                    catch (Exception ex)
                    {
                        TelemetryExtension.Current?.TrackException(ex);
                    }

                    // So we'll fall back to creating a new one
                    control = null;
                }

                if (control == null)
                {
                    control                    = new SingleDayControl(container);
                    control.ItemClick         += SingleDayControl_ItemClick;
                    control.HolidayItemClick  += SingleDayControl_HolidayItemClick;
                    control.ScheduleItemClick += SingleDayControl_ScheduleItemClick;
                    control.ScheduleClick     += SingleDayControl_ScheduleClick;
                    control.Initialize(date, homeworksOnDay, ItemsSource);
                }

                container.AddView(control);

                return(control);
            }