Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having trouble with changing weekdays in Kotlin #84

Open
kwanggy opened this issue Feb 14, 2020 · 0 comments
Open

Having trouble with changing weekdays in Kotlin #84

kwanggy opened this issue Feb 14, 2020 · 0 comments

Comments

@kwanggy
Copy link

kwanggy commented Feb 14, 2020

calendarView.weekendDays requires (Mutable)Set<Long>
so I declared mutable set and pass it to weekendDays like this

val set = mutableSetOf<Long>()
        set.add(Calerndar.SATURDAY)  // I also tried WeekDay.SATURDAY
        calendarView.weekendDays = set

However it doesn't recognize saturday as weekendDays. So I researched source code little bit and I found this snippet.
MonthAdapter.java

private void setDaysAccordingToSet(Set<Long> days, DayFlag dayFlag) {
        if (days != null && !days.isEmpty()) {
            for (Month month : months) {
                for (Day day : month.getDays()) {
                    switch (dayFlag) {
                        case WEEKEND:
                            day.setWeekend(days.contains(day.getCalendar().get(Calendar.DAY_OF_WEEK)));
                            break;

days.contains(day.getCalendar().get(Calendar.DAY_OF_WEEK)) returns false everytime, even though Set<Long> days set has "7" and day.getCalendar().get(Calendar.DAY_OF_WEEK)value is 7.
I think it's because "7" in Set<Long> days is Long type and day.getCalendar().get(Calendar.DAY_OF_WEEK) is Int type. It works when i do days.contains((long)day.getCalendar().get(Calendar.DAY_OF_WEEK))

Can anyone help me with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant