Code Monkey home page Code Monkey logo

Comments (8)

dandc87 avatar dandc87 commented on May 19, 2024

Hey @samiro, right now there isn't a way to disable individual days, only minimum and maximum dates can be set. I don't see this feature being a priority right now, unless it becomes popular.

As always, pull requests are welcome, but I would advise waiting for events (see #3) to be implemented so we can have a similar APIs.

from material-calendarview.

samiro avatar samiro commented on May 19, 2024

Ok. Thank you very much.

from material-calendarview.

johnkil avatar johnkil commented on May 19, 2024

+1

from material-calendarview.

NicolaVerbeeck avatar NicolaVerbeeck commented on May 19, 2024

+1

from material-calendarview.

jsa-nic avatar jsa-nic commented on May 19, 2024

I just wanted to point out to anyone that's interested in this feature, that I managed to implement this functionality buy implementing onDateChanged, keeping track of the currently selected date and re-setting the currently selected date if the newly selected date should be disabled. The other thing that I had to do was implement a DayViewDecorator which set the disabled day's background to the same color as the calendar background.

from material-calendarview.

dandc87 avatar dandc87 commented on May 19, 2024

Thanks for the suggestion @jsa-nic!

from material-calendarview.

dandc87 avatar dandc87 commented on May 19, 2024

Released in 0.6.0. Disabling days was added to the decorator system.

from material-calendarview.

roeiros avatar roeiros commented on May 19, 2024

@dandc87 Can you provide an example for disabling certain dates?

I was trying to do as proposed here

ArrayList<CalendarDay> enabledDates = new ArrayList<>();


            enabledDates.add(new CalendarDay(new Date(2017, 8, 25)));
            enabledDates.add(new CalendarDay(new Date(2017, 8, 26)));
            enabledDates.add(new CalendarDay(new Date(2017, 8, 27)));
            enabledDates.add(new CalendarDay(new Date(2017, 8, 28)));
            enabledDates.add(new CalendarDay(new Date(2017, 8, 29)));
            enabledDates.add(new CalendarDay(new Date(2017, 8, 30)));
            enabledDates.add(new CalendarDay(new Date(2017, 9, 1)));
            enabledDates.add(new CalendarDay(new Date(2017, 9, 10)));
            enabledDates.add(new CalendarDay(new Date(2017, 9, 11)));
            enabledDates.add(new CalendarDay(new Date(2017, 9, 13)));
            enabledDates.add(new CalendarDay(new Date(2017, 9, 16)));
            enabledDates.add(new CalendarDay(new Date(2017, 9, 19)));


            mcv.addDecorator(new DayEnableDecorator(enabledDates));
public class DayEnableDecorator implements DayViewDecorator {
        private HashSet<CalendarDay> dates;

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

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

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

However, it doesn't work and it seems like CalendarDay() is deprecated.
Any help would be appreciated.

from material-calendarview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.