From dcbeca15d954b313f0154f4646749213cee8add7 Mon Sep 17 00:00:00 2001 From: cs8898 Date: Thu, 14 Feb 2019 17:34:04 +0100 Subject: [PATCH] FIX: zooming out reveals 00:00 to 01:00 segment at the bottom (#37) * Added potentialMinHeight for a hour segment Zooming far enough out will display the segment from 00:00 to 01:00 AM on the bottom of a day // TODO: When an AllDayChip leaves the viewport it will reveal the free space below, displaying the 00:00 to 01:00AM segment * change requests --- .../weekview/WeekViewDrawingConfig.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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);