-
Notifications
You must be signed in to change notification settings - Fork 64
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
onMonthChangeListener not working as expected #83
Comments
We disabled prefetching in this fork because it shouldn't be the task of the library itself. (see #42) . It's strange that he doesn't call it on the right days, did you test with multiday view or one day view ? |
I just tested it again: in single day view mode it seems to work well, but as multiple days are visible it gets weird. In week view mode onMonthChange is called when the 8th of the next month becomes visible. So my guess
Btw I noticed the current implementation always devides by 30. Could that be a problem if the current month has a different amount of days (e.g. Feb)? (This could easily be done with instance.getActualMaximum(Calendar.DAY_OF_MONTH)) |
As to why it is only called on Feb 16th, I'm not 100% sure. Honestly, I think the library could really use some unit tests here. But I think it has to do with this line: https://github.com/Quivr/Android-Week-View/blob/develop/library/src/main/java/com/alamkanak/weekview/WeekView.java#L888 (which we might need to drop/adapt because of the PR 42 linked above)
Well, it's a very confusing interface, but basically, you can choose whatever period you want. You just need to be able to give every period a periodIndex. E.g. this could be a week, a day, hell, it could even been 1 year. In essence you can see this method as two methods:
So the day with periodIndex 2018,5 would be a day, somewhere around July 1st, 2018.
To fix thisI think there are two things we should fix:
A PrefetchWeekViewLoader could be a decorator class decorating another WeekViewLoader (So it can be used with any kind of WeekViewLoader). It has 3 lists + currentPeriodIndex as fields and basically calls the underlying WeekViewLoader 3 times on initialization and otherwise just shifts its lists to return the correct ones and calls the underlying WeekViewLoader to prefetch (cfr. the code that was removed with https://github.com/Quivr/Android-Week-View/pull/42/files). The onLoad method would then just return a list that is a concatenation of these 3 other lists. Is that clear? If so, I'd be happy to review any PR's 😄 |
Thanks a lot for your detailed explanation!
With pull request #86 this bug should be gone, some testing would be appreciated.
The second problem is a bit harder to fix. In my opinion just saying that the library shouldn't be responsible for prefetching is a mistake. For better understanding I recorded a short video: So if you have no prefetching at all there will always be problems like shown in the video, that's why it was included in the original libary. I would suggest the easiest thing is reverting pull request #42 and adjusting the lines around https://github.com/Quivr/Android-Week-View/blob/develop/library/src/main/java/com/alamkanak/weekview/WeekView.java#L888 so that getMoreEvents is called on the 15th of the last month or the 15th of the next month. (I think that's also the reason for "bug" 1, it was wanted behaviour) |
@Mc-12 This PrefetchingWeekViewLoader decorator could be part of the library. And I think most people will/should probably use it, but it should not be part of the main WeekView class as then it's impossible to not have prefetching or to implement it yourself in another way (E.g. Maybe you want to prefetch up to 5 periods). Do you see were I'm coming from? |
Please have a look at #86 😉 |
Is there anything wrong with this PR which prevents your from accepting it? |
Our team is using the library in the project, and doing a regression the QA team found that if we are in a week that shares two months (today is Tuesday October 2 and the week starts with Sunday = September 30) the items that I have today they are not loaded until the user swipes. Previously, the previous table was loaded, the current month and the next. I see that here they comment on the issue, which solution is the most recommended to follow? |
|
@crismaver1993 As the authors of this lib don't respond anymore you could either manually clone this repo and apply #89 or simply clone my repo at https://github.com/mc-12/Android-Week-View which already has this fix (and some more) included. |
Thanks ! I will do the changes and I will let you know how it works! . By the way, It is a cool library! |
Do you add your repo to Maven Central? |
Not yet. But its pretty simple to add the repo as submodule and add it to your gradle file. Just take a look at the sample project here. |
Thanks a lot ! i really apprecciate! |
Hey guys,
I'd really love to use your library as part of an app for students which includes a timetable.
After testing around a bit, I noticed that the behaviour of the onMonthChangeListener seems to be broken. When I clone your sample project and start the app (Basic Example) the debugger tells me that onMonthChange(int newYear, int newMonth) in the BasicActivity is called exactly once, in my case (Mar 29th 2018) newYear=2018 and newMonth=3.
So far, so good. Now I would expect that it it also called for newMonth=2 and newMonth=4, but that is not happening. When I scroll to the right, the listener is called on April 3rd with newMonth=4 (3 days to late) and when I scroll to the
rightleft it is called on Feb 16th with newMonth=2 (about 14 days to late).The original library by alamkanak behaves the way I would expect it and how you described it in Issue #70. It calles the listener 3 times on startup and depending on the direction again when needed.
Please have a look at this bug or tell me what I am doing wrong.
Thanks!
The text was updated successfully, but these errors were encountered: