Exemple #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.one_day_picker_activity);

            MV.CalendarView calendarView = (MV.CalendarView)FindViewById(Resource.Id.calendarView);

            Calendar min = Calendar.Instance;

            min.Add(CalendarField.Month, -2);

            Calendar max = Calendar.Instance;

            max.Add(CalendarField.Month, 2);

            calendarView.SetMinimumDate(min);
            calendarView.SetMaximumDate(max);

            Button getDateButton = (Button)FindViewById(Resource.Id.getDateButton);

            getDateButton.Click += (sender, e) =>
            {
                calendarView.SelectedDates.ToList().ForEach(d =>
                                                            Toast.MakeText(this, d.Time.ToString(), ToastLength.Short).Show());
            };
        }
Exemple #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _databaseService = new DatabaseService();
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Home);

            // Adding Toolbar to Main screen
            Toolbar toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            toolbar.Title = "Kalendorius";
            SetSupportActionBar(toolbar);


            MV.CalendarView calendarView = (MV.CalendarView)FindViewById(Resource.Id.calendarView);

            List <MV.EventDay> events = new List <MV.EventDay>();

            foreach (var dayEvent in _databaseService.GetUserEvents())
            {
                Calendar calendar = Calendar.Instance;
                calendar.Set(dayEvent.Time.Year, dayEvent.Time.Month - 1, dayEvent.Time.Day);
                switch (dayEvent.Category)
                {
                case "Egzaminas":
                    events.Add(new MV.EventDay(calendar, Resource.Drawable.egzas));
                    break;

                case "Teorija":
                    events.Add(new MV.EventDay(calendar, Resource.Drawable.teorija));
                    break;

                case "Testas":
                    events.Add(new MV.EventDay(calendar, Resource.Drawable.laborai));
                    break;

                case "Praktika":
                    events.Add(new MV.EventDay(calendar, Resource.Drawable.laborai));
                    break;

                case "Laboratoriniai":
                    events.Add(new MV.EventDay(calendar, Resource.Drawable.laborai));
                    break;
                }
            }

            calendarView.SetEvents(events);
            calendarView.DayClick += CalendarView_DayClick;
        }
Exemple #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Activity_calendar);

            // Set toolbar
            Android.Widget.Toolbar toolbar = FindViewById <Android.Widget.Toolbar>(Resource.Id.toolbar);
            toolbar.Title = "Calendar";
            SetActionBar(toolbar);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetDisplayShowHomeEnabled(true);

            mCalendarView = FindViewById <CalendarView>(Resource.Id.calendar);
            initCalendar();
            mCalendarView.DayClick += (o, e) => {
                bool hasEvent = false;
                foreach (KeyValuePair <string, List <HMEvent> > entry in mDict)
                {
                    String dateStr = new SimpleDateFormat("MM-dd-yyyy").Format(e.P0.Calendar.Time);
                    if (entry.Key.Equals(dateStr))
                    {
                        List <HMEvent> events       = entry.Value;
                        RecyclerView   recyclerView = new RecyclerView(this);
                        recyclerView.SetLayoutManager(new LinearLayoutManager(this));
                        BottomSheetDialog dialog  = new BottomSheetDialog(this);
                        CalendarAdapter   adapter = new CalendarAdapter(this, dialog, events);
                        recyclerView.SetAdapter(adapter);
                        dialog.SetContentView(recyclerView);
                        dialog.Show();
                        dialog.SetOnDismissListener(this);
                        if (!mAdapterDict.ContainsKey(dateStr))
                        {
                            mAdapterDict.Add(dateStr, adapter);
                        }
                        hasEvent = true;
                        break;
                    }
                }
                if (!hasEvent)
                {
                    Intent intent = new Intent(this, typeof(CalendarEditAcitvity));
                    StartActivityForResult(intent, CalendarAdapter.ADD);
                }
            };
        }
Exemple #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.many_days_picker_activity);

            MV.CalendarView calendarView = (MV.CalendarView)FindViewById(Resource.Id.calendarView);

            Button getDateButton = (Button)FindViewById(Resource.Id.getDateButton);

            getDateButton.Click += (sender, e) =>
            {
                calendarView.SelectedDates.ToList().ForEach(d =>
                                                            Toast.MakeText(this, d.Time.ToString(), ToastLength.Short).Show());
                Toast.MakeText(this, calendarView.SelectedDate.Time.ToString(),
                               ToastLength.Long).Show();
            };
        }
Exemple #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.calendar_activity);

            List <EventDay> events = new List <EventDay>();

            Calendar calendarToday = Calendar.Instance;

            events.Add(new EventDay(calendarToday, Resource.Drawable.sample_icon_1));

            Calendar calendarTwoDaysFromToday = Calendar.Instance;

            calendarTwoDaysFromToday.Add(CalendarField.DayOfMonth, 2);
            events.Add(new EventDay(calendarTwoDaysFromToday, Resource.Drawable.sample_icon_2));

            calendarToday.ToDateTime();
            Calendar calendarFiveDaysFromToday = Calendar.Instance;

            calendarFiveDaysFromToday.Add(CalendarField.DayOfMonth, 5);
            events.Add(new EventDay(calendarFiveDaysFromToday, Resource.Drawable.sample_icon_3));

            MCV.CalendarView calendarView = (MCV.CalendarView)FindViewById(Resource.Id.calendarView);

            calendarView.PreviousButtonClick += (sender, e) =>
                                                Toast.MakeText(this, "LEFT", ToastLength.Short).Show();

            calendarView.ForwardButtonClick += (sender, e) =>
                                               Toast.MakeText(this, "RIGHT", ToastLength.Short).Show();

            Calendar min = Calendar.Instance;

            min.Add(CalendarField.Month, -2);

            Calendar max = Calendar.Instance;

            max.Add(CalendarField.Month, 2);

            calendarView.SetMinimumDate(min);
            calendarView.SetMaximumDate(max);

            calendarView.SetEvents(events);

            calendarView.DayClick += (sender, e) =>
            {
                Toast.MakeText(this, e.P0.Calendar.Time.ToString(),
                               ToastLength.Short).Show();
            };

            Button setDateButton = (Button)FindViewById(Resource.Id.setDateButton);

            setDateButton.Click += (sender, e) =>
            {
                try
                {
                    calendarView.SetDate(GetRandomCalendar());
                }
                catch (OutOfDateRangeException exception)
                {
                    exception.PrintStackTrace();
                    Toast.MakeText(this, "Date is out of range", ToastLength.Short).Show();
                }
            };
        }