- handle negative endTimeOffset
- deduplicated code
This commit is contained in:
		@@ -367,12 +367,11 @@ public class LoadingBar extends AbstractProgressBar {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   private long getMinLunchDuration(int endTimeOffset) {
 | 
			
		||||
      if (endTimeOffset == 0) {
 | 
			
		||||
      if (endTimeOffset <= 0) {
 | 
			
		||||
         return MIN_LUNCH_DURATION;
 | 
			
		||||
      }
 | 
			
		||||
      long totalDuration = MAX_NUMBER_WORK_MINS + endTimeOffset;
 | 
			
		||||
      long effectiveLunchDuration = totalDuration - MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH;
 | 
			
		||||
      return getMinLunchDuration(effectiveLunchDuration);
 | 
			
		||||
      return getMinLunchDuration(totalDuration);
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -381,12 +380,12 @@ public class LoadingBar extends AbstractProgressBar {
 | 
			
		||||
         return MIN_LUNCH_DURATION;
 | 
			
		||||
      }
 | 
			
		||||
      long totalDuration = getStartTime().until(manualEndTime, ChronoUnit.MINUTES);
 | 
			
		||||
      long effectiveLunchDuration = totalDuration - MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH;
 | 
			
		||||
      return getMinLunchDuration(effectiveLunchDuration);
 | 
			
		||||
      return getMinLunchDuration(totalDuration);
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   private long getMinLunchDuration(long effectiveLunchDuration) {
 | 
			
		||||
   private long getMinLunchDuration(long precalculatedTotalDuration) {
 | 
			
		||||
      long effectiveLunchDuration = precalculatedTotalDuration - MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH;
 | 
			
		||||
      if (effectiveLunchDuration < 0) {
 | 
			
		||||
         effectiveLunchDuration = 0;
 | 
			
		||||
      }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user