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

setCalendarDisplayMode(CalendarMode.WEEKS) wrong week when Date selected #222

Closed
ghost opened this issue Jan 28, 2016 · 18 comments
Closed
Labels

Comments

@ghost
Copy link

ghost commented Jan 28, 2016

When you "collapse" the Calendar with .setCalendarDisplayMode(CalendarMode.WEEKS), the week displayed is one week to early, when using Monday as first day of the week. (Only working when i select the Sunday)
[BUG]

@ekchang ekchang added the bug label Jan 31, 2016
@victorileaf
Copy link

its not working even if i set to Sunday .. on lollipop and above.
Works on pre-lolliop devices. if first day is Sunday.

problem with setCurrentDate
date set to Saturday or Sunday of the week in Week View.

eg:
In weekview (Today:30/6/16)
CurrentDate: CalendarDay{2016-2-26} selected Date: CalendarDay{2016-2-30}

@Nuclominus
Copy link

Same bug on marshmallow, but week switches to the desired week if setCurrentTime set for Sunday
There is fast fix - just add one week to the current date.
Calendar now = Calendar.getInstance();
now.add(Calendar.DATE, 7);
calendarView.setCurrentDate(CalendarDay.from(now), true);

@joecizac
Copy link

Adding dayDiff += (Calendar.DAY_OF_WEEK_IN_MONTH - firstDayOfTheWeek) % 7; between line 69-70 in WeekPagerAdapter#weekNumberDifference(...) seems to fix this.
Expose 'firstDayOfTheWeek' in CalendarPagerAdapter with 'public static' modifier.

@quentin41500
Copy link
Member

@joecizac Thanks for your answer we are going to check that out

@quentin41500
Copy link
Member

This issue has been fixed and is available in the 1.3 snapshot. Stay tuned for the next release.You can try the 1.3 snapshot with the instructions in README. Enjoy and report issues!

@ekchang ekchang closed this as completed May 16, 2016
@joecizac
Copy link

joecizac commented May 25, 2016

The issue still persists in nexus 5 running on 6.0.1...dunno why...
Working on other phones though.

@victorileaf
Copy link

victorileaf commented May 25, 2016

yes issue still persists in marshmallow ... i have use a hack to scroll the pager in Week view. its working fine in lollipop and below i think

@joecizac
Copy link

And the problem aggravates with setMaximumDate

@ekchang
Copy link
Contributor

ekchang commented May 25, 2016

@joecizac @victorileaf Can you provide full details on the MCV configuration you are using to repro this issue?

Also, we encourage you to try out the 1.4.0-SNAPSHOT and see if the issue is present. It is known that for 1.3.0 and below the order in which certain setters are called will affect the final state of the MCV, especially setMin/MaxDate, CalendarMode, and FirstDayOfWeek. It is hopefully resolved with 1.4.0 with the introduction of the state builder.

@ekchang ekchang reopened this May 25, 2016
@joecizac
Copy link

joecizac commented May 25, 2016

mCalendarView = (MaterialCalendarView) parent.findViewById(R.id.cal_week); mCalendarView.setShowOtherDates(MaterialCalendarView.SHOW_ALL); mCalendarView.setSelectedDate(now.getTime()); mCalendarView.setCurrentDate(CalendarDay.from(now), false); mCalendarView.setMaximumDate(now.getTime());

@ekchang
Copy link
Contributor

ekchang commented May 25, 2016

For 1.3.0 and below, you should call setMaxDate before Current/Selected; min/max does things which rebuild the adapters and is especially sensitive for Week mode.

Setting Min/Max Date, CalendarMode, and FirstDayOfWeek should always be the first things to configure for MCV because of its stateful nature.

EDIT: Was able to repro issue using today (05/25/16) with the above params. Bug is still present in 1.4.0 This is sadly a known issue regarding setting Max date in Week mode, and it is unclear what exactly is causing it. Will dive deeper into setting max date implementation when I have time. (This is one of the primary reasons Week mode is marked @Experimental)

@ekchang ekchang added this to the 1.X milestone May 25, 2016
@joecizac
Copy link

The issue is with Marshmallow and N preview.

@ekchang
Copy link
Contributor

ekchang commented May 25, 2016

No, it's not platform specific. I can repro this even on a 5.1 device. This snippet will break on 1.4.0 for example:

CalendarDay today = CalendarDay.from(2016, 4, 25);

widget.state().edit()
  .setMaximumDate(today)
  .setCalendarDisplayMode(CalendarMode.WEEKS)
  .commit();

widget.setCurrentDate(today);
widget.setSelectedDate(today);

@joecizac
Copy link

So this bug should be re-opened right?

@ekchang
Copy link
Contributor

ekchang commented May 26, 2016

It has already been reopened.

@ekchang
Copy link
Contributor

ekchang commented Jun 1, 2016

Fixed in 1.4.0

@lopezzbelgium
Copy link

I still have this issue on 1.4.0 when using monday as firstDayOfWeek

@NehaSukhlecha
Copy link

NehaSukhlecha commented Feb 17, 2017

issue in marshmallow and above selecting wrong week..and i don't want set max date..

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

No branches or pull requests

7 participants