refactored duplicate code to superclass

This commit is contained in:
Kai Börnert committed 2016-11-23 09:31:00 +01:00
1 parent 36a93b7c26
commit 0e9bd289fc
3 files changed
+11 -5

No files matched your search

@@ -62,7 +62,6 @@ import com.sap.sse.gwt.client.async.AsyncActionsExecutor;
import com.sap.sse.gwt.client.player.TimeRangeWithZoomProvider;
import com.sap.sse.gwt.client.player.Timer;
import com.sap.sse.gwt.client.player.Timer.PlayModes;
import com.sap.sse.gwt.client.player.Timer.PlayStates;
import com.sap.sse.gwt.client.shared.components.Component;
/**
@@ -224,8 +223,7 @@ public abstract class AbstractCompetitorRaceChart<SettingsType extends ChartSett
if (isVisible()) {
// if no data is loaded yet, or if it is not playing and not live (append loading every second) show loading
// indicator
if (primary.timeOfLatestRequestInMillis == null
|| (timer.getPlayState() != PlayStates.Playing && timer.getPlayMode() != PlayModes.Live)) {
if (shouldShowLoading(primary.timeOfLatestRequestInMillis)) {
showLoading(stringMessages.loadingCompetitorData());
}
ArrayList<CompetitorDTO> competitorsToLoad = new ArrayList<CompetitorDTO>();
@@ -35,6 +35,7 @@ import com.sap.sse.gwt.client.player.TimeRangeWithZoomProvider;
import com.sap.sse.gwt.client.player.TimeZoomChangeListener;
import com.sap.sse.gwt.client.player.Timer;
import com.sap.sse.gwt.client.player.Timer.PlayModes;
import com.sap.sse.gwt.client.player.Timer.PlayStates;
import com.sap.sse.gwt.client.shared.components.Component;
import com.sap.sse.gwt.client.shared.components.SettingsDialog;
@@ -257,4 +258,12 @@ public abstract class AbstractRaceChart<SettingsType extends Settings> extends A
public String getId() {
return getLocalizedShortName();
}
/**
* Returns true if a normal loading message is allowed to appear over the
*/
public boolean shouldShowLoading(Long timestamp) {
return timestamp == null
|| (timer.getPlayState() != PlayStates.Playing && timer.getPlayMode() != PlayModes.Live);
}
}
@@ -56,7 +56,6 @@ import com.sap.sse.gwt.client.async.AsyncActionsExecutor;
import com.sap.sse.gwt.client.player.TimeRangeWithZoomProvider;
import com.sap.sse.gwt.client.player.Timer;
import com.sap.sse.gwt.client.player.Timer.PlayModes;
import com.sap.sse.gwt.client.player.Timer.PlayStates;
import com.sap.sse.gwt.client.shared.components.SettingsDialog;
import com.sap.sse.gwt.client.shared.components.SettingsDialogComponent;
@@ -470,7 +469,7 @@ public class WindChart extends AbstractRaceChart<WindChartSettings> implements R
} else if (needsDataLoading() && from != null && to != null) {
setWidget(chart);
// if not playing or empty show loading message
if (timer.getPlayState() != PlayStates.Playing || timeOfLatestRequestInMillis == null) {
if (shouldShowLoading(timeOfLatestRequestInMillis)) {
showLoading(stringMessages.windChartLoading());
}
GetWindInfoAction getWindInfoAction = new GetWindInfoAction(sailingService, selectedRaceIdentifier,