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