CalendarView.java was updated to fix various drawing bugs #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've added comments to all of the changed areas to explain why I made the changes and what bugs the changes fix. I've tested the changes extensively.
Here's the edge case example I mentioned in my comments:
Obviously, the loop in WeekView.init() used to populate the mDayNumbers[] array increments mTempDate by EXACTLY one day each time it executes. This can cause a bug when mTempDate finally increments to be the same day as mMaxDate.
To better explain the bug, here's an example. Say the time of day of mMinDate is 5:00pm, and the time of day of mMaxDate is 3:00pm. When mTempDate is finally incremented enough that it is the same DAY as mMaxdate, its time of day is still 2 hours past the time of day of mMaxDate.
Due to this, even though the day number of mTempDate SHOULD be drawn, the original code won't draw it, because the boolean expression used in the aforementioned loop only tests to see if mTempDate is after mMaxDate.
To fix this, the loop now also tests to see if mTempDate is the same day as mMaxDate (Using the already existing isSameDate() method).
This ensures that the day number for mMaxDate is drawn even if the time of day of mTempDate puts mTempDate after mMaxDate, so long as mTempDate and mMaxDate have the same DAY_OF_YEAR and YEAR values.
The reason WeeksAdapter.onTouch() was modified was because otherwise even though the number is drawn, we still wouldn't be able to select it for the same reasons given above.
Apologies for this explanation being so lengthy.