Material-calendarview: How to DisableDecorator to one days of week?

Created on 28 Feb 2016  路  11Comments  路  Source: prolificinteractive/material-calendarview

I need DisableDecorator to one days of week. for example disale Decorator for all Monday days.
How to do it using method

   private class PrimeDayDisableDecorator implements DayViewDecorator {

   }  

thanks

Most helpful comment

@erioana If you wanna disable Mondays:

    private static class PrimeDayDisableDecorator implements DayViewDecorator {

        @Override
        public boolean shouldDecorate(CalendarDay day) {
            day.copyTo(calendar);
            int weekDay = calendar.get(Calendar.DAY_OF_WEEK);
            return weekDay == Calendar.MONDAY;
        }

        @Override
        public void decorate(DayViewFacade view) {
            view.setDaysDisabled(true);
        }
    }

@Brucezh If you want to disable specific days or just one day. You can pass just one day or a collection:

    private static class PrimeDayDisableDecorator implements DayViewDecorator {

        private HashSet<CalendarDay> dates;

        public PrimeDayDisableDecorator(Collection<CalendarDay> dates) {
            this.dates = new HashSet<>(dates);
         }

        @Override
        public boolean shouldDecorate(CalendarDay day) {
            dates.contains(day);
        }

        @Override
        public void decorate(DayViewFacade view) {
            view.setDaysDisabled(true);
        }
    }

All 11 comments

I also need the function.Have you made it????

+1

+1

I am very urgent.I am very eager to know....

Seeking master......

Reading the decorators doc will help https://github.com/prolificinteractive/material-calendarview/blob/master/docs/DECORATORS.md.

You would just pass in a collection of all mondays and then you can decorate just the mondays.

@emitchel Thank you very much

@emitchel but I want to disable one day of week not several days. The function can be achieved?

@Brucezh Just pass in one day into the constructor, i.e. One Decorator class for the day - not efficient but it works.

@erioana If you wanna disable Mondays:

    private static class PrimeDayDisableDecorator implements DayViewDecorator {

        @Override
        public boolean shouldDecorate(CalendarDay day) {
            day.copyTo(calendar);
            int weekDay = calendar.get(Calendar.DAY_OF_WEEK);
            return weekDay == Calendar.MONDAY;
        }

        @Override
        public void decorate(DayViewFacade view) {
            view.setDaysDisabled(true);
        }
    }

@Brucezh If you want to disable specific days or just one day. You can pass just one day or a collection:

    private static class PrimeDayDisableDecorator implements DayViewDecorator {

        private HashSet<CalendarDay> dates;

        public PrimeDayDisableDecorator(Collection<CalendarDay> dates) {
            this.dates = new HashSet<>(dates);
         }

        @Override
        public boolean shouldDecorate(CalendarDay day) {
            dates.contains(day);
        }

        @Override
        public void decorate(DayViewFacade view) {
            view.setDaysDisabled(true);
        }
    }

Thanks @quentin41500

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ashtapathy picture Ashtapathy  路  3Comments

TokyoAndroid picture TokyoAndroid  路  4Comments

vincent-etienne picture vincent-etienne  路  7Comments

Xirate picture Xirate  路  5Comments

gibsonndemanga picture gibsonndemanga  路  6Comments