Skip to content

Commit 7341ef3

Browse files
author
marunjar
committed
change goToHour
shuffle code a little bit: return immediately if mAreDimensionsInvalid calculate verticalOffset only if necessary
1 parent 39fd130 commit 7341ef3

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

library/src/main/java/com/alamkanak/weekview/WeekView.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,16 +1420,18 @@ public void notifyDatasetChanged(){
14201420
* @param hour The hour to scroll to in 24-hour format. Supported values are 0-24.
14211421
*/
14221422
public void goToHour(double hour){
1423-
int verticalOffset = (int) (mHourHeight * hour);
1424-
if (hour < 0)
1425-
verticalOffset = 0;
1426-
else if (hour > 24)
1427-
verticalOffset = mHourHeight * 24;
1428-
14291423
if (mAreDimensionsInvalid) {
14301424
mScrollToHour = hour;
14311425
return;
1432-
} else if (verticalOffset > mHourHeight * 24 - getHeight() + mHeaderTextHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom)
1426+
}
1427+
1428+
int verticalOffset = 0;
1429+
if (hour > 24)
1430+
verticalOffset = mHourHeight * 24;
1431+
else if (hour > 0)
1432+
verticalOffset = (int) (mHourHeight * hour);
1433+
1434+
if (verticalOffset > mHourHeight * 24 - getHeight() + mHeaderTextHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom)
14331435
verticalOffset = (int)(mHourHeight * 24 - getHeight() + mHeaderTextHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom);
14341436

14351437
mCurrentOrigin.y = -verticalOffset;

0 commit comments

Comments
 (0)