예제 #1
0
        public TimetableView(Context context, Timetable timetable, Day day, TimetableFragment ttf) : base(context)
        {
            Orientation = Orientation.Horizontal;

            hourLayout             = new LinearLayout(context);
            hourLayout.Orientation = Orientation.Vertical;
            AddView(hourLayout);

            /*
             * Deze is er alleen om de uren op de goede plaats te krijgen
             */
            dummyDateView = new DateTitleView(context, null);
            hourLayout.AddView(dummyDateView);

            hourView = new HourView(context, TimeLayout.DefaultStartHour, TimeLayout.DefaultEndHour);
            hourLayout.AddView(hourView);

            dayView = new MultiDayView(context, timetable, day, hourView, ttf);
            hourView.AddHourHeightListener(dayView);
            AddView(dayView);
        }
예제 #2
0
        protected override void Update()
        {
            RemoveAllViews();

            dtView = new DateTitleView(Context, Day);
            AddView(dtView);

            var dayEvents = Timetable.GetEvents(Day, day => {}, (day, events) => Update(), e =>
            {
                errorUpdating = e;
                Console.WriteLine(e);
                Update();
            });

            if (errorUpdating != null && !dayEvents.Any())
            {
                TextView errorText = new TextView(Context);
                errorText.Text = "Er is een fout opgetreden:\n\n"
                                 + errorUpdating.ToShortString() + "\n\n"
                                 + "Raak deze tekst aan om het opnieuw te proberen.";
                errorText.Gravity          = GravityFlags.Center;
                errorText.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                int padding = Utils.DpToPx(40);
                errorText.SetPadding(padding, 0, padding, 0);
                errorText.Clickable = true;
                errorText.Click    += (sender, e) =>
                {
                    errorUpdating = null;
                    Update();
                };
                AddView(errorText);
            }
            else
            {
                if (Timetable.UpdatesInProgress.Contains(Day.Week))
                {
                    AddView(new LoadingView(Context));
                }
                else
                {
                    if (dayScrollView != null)
                    {
                        dayScrollView.Unlink();
                    }
                    dayScrollView = new LinkedScrollView(Context);
                    dayScrollView.LinkTo(HourView.ScrollView);
                    dayScrollView.VerticalScrollBarEnabled = showScroll;
                    if (Build.VERSION.SdkInt >= BuildVersionCodes.GingerbreadMr1)
                    {
                        dayScrollView.OverScrollMode = OverScrollMode.Never;
                    }
                    AddView(dayScrollView);

                    RelativeLayout layout = MakeLayout(dayEvents, StartHour);
                    layout.SetPadding(0, HourHeight / 2, 0, 0);
                    int numHours = HourView.EndHour - HourView.StartHour + 1;
                    layout.LayoutParameters.Width  = LayoutParams.MatchParent;
                    layout.LayoutParameters.Height = numHours * HourView.HourHeight;
                    //layout.SetMinimumHeight(numHours * HourView.HourHeight);
                    //Console.WriteLine("MinHeight: " + numHours * HourView.HourHeight);
                    dayScrollView.AddView(layout);
                }
            }
        }