Skip to content

Conversation

@bkromhout
Copy link

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.

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.
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

Successfully merging this pull request may close these issues.

1 participant