diff --git a/library/src/main/java/com/alamkanak/weekview/WeekViewDrawingConfig.java b/library/src/main/java/com/alamkanak/weekview/WeekViewDrawingConfig.java index bb8925044..b58b97459 100644 --- a/library/src/main/java/com/alamkanak/weekview/WeekViewDrawingConfig.java +++ b/library/src/main/java/com/alamkanak/weekview/WeekViewDrawingConfig.java @@ -211,11 +211,15 @@ int computeDifferenceWithFirstDayOfWeek(@NonNull WeekViewConfig config ,@NonNull void refreshAfterZooming(WeekViewConfig config) { if (newHourHeight > 0 && !config.showCompleteDay) { - if (newHourHeight < config.effectiveMinHourHeight) { - newHourHeight = config.effectiveMinHourHeight; - } else if (newHourHeight > config.maxHourHeight) { - newHourHeight = config.maxHourHeight; - } + newHourHeight = Math.max(newHourHeight, config.effectiveMinHourHeight); + newHourHeight = Math.min(newHourHeight, config.maxHourHeight); + + // potentialMinHourHeight + // the minimal height of an hour when zoomed completely out + // needed to suppress the zooming below 24:00 + final int height = WeekView.getViewHeight(); + float potentialMinHourHeight = (height - headerHeight) / Constants.HOURS_PER_DAY; + newHourHeight = Math.max(newHourHeight, potentialMinHourHeight); currentOrigin.y = (currentOrigin.y / config.hourHeight) * newHourHeight; config.hourHeight = newHourHeight; @@ -227,7 +231,7 @@ void updateVerticalOrigin(WeekViewConfig config) { final int height = WeekView.getViewHeight(); // If the new currentOrigin.y is invalid, make it valid. - final float dayHeight = config.hourHeight * 24; + final float dayHeight = config.hourHeight * Constants.HOURS_PER_DAY; final float potentialNewVerticalOrigin = height - (dayHeight + headerHeight);