thellmund / Android-Week-View

Display highly customizable calendar views in your Android app
Apache License 2.0
188 stars 97 forks source link

Wrong month called with the month loader #115

Closed Caceresenzo closed 5 years ago

Caceresenzo commented 5 years ago

Describe the bug While going to one month to another, the monthloader seems to "loose" the previous month. (English is not my first language, and i am not sure how to describe my problem, sorry for my bad writing)

Here are the logs while switching from month to month:

D/ScheduleFragment: xx 2019/10    to    2019/10
D/ScheduleFragment: xx 2019/7     to    2019/7
D/ScheduleFragment: xx 2019/10    to    2019/10
D/ScheduleFragment: xx 2019/7     to    2019/7
D/ScheduleFragment: xx 2019/10    to    2019/10
D/ScheduleFragment: xx 2019/7     to    2019/7

If you haven't understand anything, take a look at the gif below

To Reproduce Steps to reproduce the behavior:

  1. Load a lot of events (in multiple month)
  2. Slowly swipe at the first of the month to the last day of the previous month

Expected behavior I've tested with the version 3.2.1, everything was working fine.

Screenshots If applicable, add screenshots or a screen recording to help explain your problem.

Additional context bug

Caceresenzo commented 5 years ago

Oh my god....

I was still using the (very) old function to "match" event to a specific month and year. The problem was the month - 1, removing it fixed everything.

Old function:

public static boolean eventMatches(VirtualCalendarEvent event, int year, int month) {
    Calendar startTime = event.getStart().toCalendar();
    Calendar endTime = event.getEnd().toCalendar();

    return (startTime.get(Calendar.YEAR) == year && startTime.get(Calendar.MONTH) == month - 1)
            || (endTime.get(Calendar.YEAR) == year && endTime.get(Calendar.MONTH) == month - 1);
}

Modification:

    return (startTime.get(Calendar.YEAR) == year && startTime.get(Calendar.MONTH) == month)
        || (endTime.get(Calendar.YEAR) == year && endTime.get(Calendar.MONTH) == month);
thellmund commented 5 years ago

Glad it’s working now 😊