Fixed problems related to live races without start time

This commit is contained in:
Steffen Schaefer committed 2015-05-21 12:47:08 +02:00
1 parent dc1a57c45d
commit 27b2af2a95
2 files changed
+9 -4

No files matched your search

@@ -1,6 +1,7 @@
package com.sap.sailing.gwt.ui.shared.dispatch.event;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.sap.sailing.gwt.ui.shared.dispatch.DTO;
@@ -14,7 +15,10 @@ public class LiveRacesDTO implements DTO {
public void addRace(LiveRaceDTO race) {
for(int i = 0; i < races.size(); i++) {
if(races.get(i).getStart().compareTo(race.getStart()) < 0) {
LiveRaceDTO foundRace = races.get(i);
Date foundStart = foundRace.getStart();
Date newStart = race.getStart();
if(foundStart == null || (newStart != null && foundStart.compareTo(newStart) < 0)) {
races.add(i, race);
return;
}
@@ -213,7 +213,8 @@ public class RaceContext {
TimePoint startTime = null;
if (trackedRace != null) {
startTime = trackedRace.getStartOfRace();
} else if (state != null) {
}
if (startTime == null && state != null) {
startTime = state.getStartTime();
}
return startTime;
@@ -274,7 +275,7 @@ public class RaceContext {
if(abortingFlagEvent != null) {
TimePoint abortingTimeInPassBefore = abortingFlagEvent.getLogicalTimePoint();
if (now.minus(abortingTimeInPassBefore.asMillis()).asMillis() < TIME_TO_SHOW_CANCELED_RACES_AS_LIVE) {
// result = true;
result = true;
// TODO: Problem: This causes the race added to the live races list without having a start time!!!
// This does not work right now -> consider using a start time of the last pass.
}
@@ -297,7 +298,7 @@ public class RaceContext {
private RaceViewState getRaceViewState(TimePoint startTime, TimePoint finishTime) {
RaceViewState raceState = RaceViewState.RUNNING;
if (now.before(startTime)) {
if (startTime != null && now.before(startTime)) {
raceState = RaceViewState.SCHEDULED;
} else if (finishTime != null && now.after(finishTime)) {
raceState = RaceViewState.FINISHED;