mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-09 22:01:02 +00:00
Merge branch 'racecommittee_app' of ssh://10.18.22.156:12349/home/trac/git into racecommittee_app
This commit is contained in:
commit
91cc2805f1
17 files changed
+542
-261
No files matched your search
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.sap.sailing.domain.common.racelog;
|
||||
|
||||
public enum StartProcedureType {
|
||||
RRS26("Fix Line Start (RRS26)"),
|
||||
GateStart("Gate Start"),
|
||||
//RRS26("Fix Line Start (RRS26)"),
|
||||
//GateStart("Gate Start"),
|
||||
ESS("\"Extreme Sailing Series\"-Start");
|
||||
|
||||
private String displayName;
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ public class RaceLogEventSerializerChooserTest {
|
||||
@Test
|
||||
public void testStartProcedureTypeChangedSerializer() {
|
||||
// we use the real event type here because we do not want to re-implement the dispatching.
|
||||
RaceLogEvent event = factory.createStartProcedureChangedEvent(null, 0, StartProcedureType.GateStart);
|
||||
RaceLogEvent event = factory.createStartProcedureChangedEvent(null, 0, StartProcedureType.ESS);
|
||||
assertEquals(startProcedureTypeChangedEventSerializer, chooser.getSerializer(event));
|
||||
}
|
||||
|
||||
|
||||
+63
-24
@@ -44,35 +44,45 @@
|
||||
android:layout_weight="0.618"
|
||||
android:gravity="fill_horizontal"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/upFlagsSpace"
|
||||
<RelativeLayout
|
||||
android:id="@+id/topFlagsSpace"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/currentlyDisplayedFlag"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="130dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginRight="50dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:contentDescription="@string/start_mode_flag"
|
||||
android:src="@drawable/ap_flag" />
|
||||
|
||||
<com.sap.sailing.racecommittee.app.ui.views.VerticalTextView
|
||||
android:id="@+id/flagsUpLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/flags_up"
|
||||
android:textAppearance="@style/TextAppearance.Welter.VeryBigTitleLabel" />
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/classFlagUp"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="130dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:contentDescription="@string/start_mode_flag"
|
||||
android:src="@drawable/generic_class"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/startModeFlagUp"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="130dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_toLeftOf="@+id/flagsUpLabel"
|
||||
android:contentDescription="@string/start_mode_flag"
|
||||
android:src="@drawable/papa_flag"
|
||||
android:visibility="gone"/>
|
||||
</RelativeLayout>
|
||||
<RelativeLayout
|
||||
android:id="@+id/downFlagsSpace"
|
||||
android:layout_width="fill_parent"
|
||||
@@ -80,15 +90,6 @@
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/nextFlagToBeDisplayed"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="130dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginRight="10dp"
|
||||
android:contentDescription="@string/start_mode_flag"
|
||||
android:src="@drawable/three_min_flag" />
|
||||
|
||||
<com.sap.sailing.racecommittee.app.ui.views.VerticalTextView
|
||||
android:id="@+id/flagsDownLabel"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -98,6 +99,27 @@
|
||||
android:layout_marginRight="10dp"
|
||||
android:text="@string/flags_down"
|
||||
android:textAppearance="@style/TextAppearance.Welter.VeryBigTitleLabel" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/classFlagDown"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="130dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:contentDescription="@string/start_mode_flag"
|
||||
android:src="@drawable/generic_class" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/startModeFlagDown"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="130dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_toLeftOf="@+id/flagsDownLabel"
|
||||
android:contentDescription="@string/start_mode_flag"
|
||||
android:src="@drawable/papa_flag" />
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -115,6 +137,23 @@
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/startModeButton"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="110dp"
|
||||
android:contentDescription="@string/choose_start_mode_flag"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/startmode_flags" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/startModeButtonLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:text="@string/choose_startmode"
|
||||
android:textAppearance="@style/TextAppearance.Welter.TitleLabel" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/abortingFlagButton"
|
||||
android:layout_width="200dp"
|
||||
|
||||
@@ -116,7 +116,8 @@
|
||||
<string name="race_startphase_ess_countdown_three_flag_display">%1$s until Three flag is displayed</string>
|
||||
<string name="race_startphase_countdown_class_remove">%1$s until %2$s class flag is removed and race starts</string>
|
||||
<string name="race_startphase_ess_countdown_one_flag_remove">%1$s until One flag is removed and race starts</string>
|
||||
<string name="race_startphase_countdown_class_display">%1$s until %2$s class flag is displayed</string><string name="race_startphase_countdown_start">%1$s until %2$s starts"</string>
|
||||
<string name="race_startphase_countdown_class_display">%1$s until %2$s class flag is displayed</string>
|
||||
<string name="race_startphase_countdown_start">%1$s until %2$s starts"</string>
|
||||
<string name="race_startphase_gate_class_over_golf_display">%1$s until Class flag over Golf flag is displayed</string>
|
||||
<string name="race_startphase_gate_class_over_golf_removed">%1$s until Class flag over Golf flag is removed and race starts</string>
|
||||
<string name="race_startphase_gate_papa_display">%1$s until Papa flag is displayed</string>
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.sap.sailing.racecommittee.app.domain.startprocedure;
|
||||
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
|
||||
public interface StartModeChoosableStartProcedure extends StartProcedure{
|
||||
void setStartModeFlag(Flags startModeFlag);
|
||||
Flags getCurrentStartModeFlag();
|
||||
}
|
||||
+1
-1
@@ -48,7 +48,7 @@ public interface StartProcedure {
|
||||
|
||||
void setStartPhaseEventListener(StartPhaseEventListener listener);
|
||||
|
||||
Pair<String, Long> getNextFlagCountdownUiLabel(Context context, long millisecondsTillStart);
|
||||
Pair<String, List<Object>> getNextFlagCountdownUiLabel(Context context, long millisecondsTillStart);
|
||||
|
||||
void handleStartProcedureSpecificEvent(TimePoint eventTime, Integer eventId);
|
||||
|
||||
|
||||
+13
-7
@@ -346,18 +346,24 @@ public class ExtremeSailingSeriesStartProcedure implements StartProcedure {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<String, Long> getNextFlagCountdownUiLabel(Context context, long millisecondsTillStart) {
|
||||
Pair<String, Long> result;
|
||||
public Pair<String, List<Object>> getNextFlagCountdownUiLabel(Context context, long millisecondsTillStart) {
|
||||
Pair<String, List<Object>> result;
|
||||
List<Object> milisecondsList = new ArrayList<Object>();
|
||||
if (millisecondsTillStart < startPhaseESSOneUpInterval) {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_ess_countdown_one_flag_remove), millisecondsTillStart);
|
||||
milisecondsList.add(millisecondsTillStart);
|
||||
result = new Pair<String, List<Object>>(context.getResources().getString(R.string.race_startphase_ess_countdown_one_flag_remove), milisecondsList );
|
||||
} else if (millisecondsTillStart < startPhaseESSTwoUpInterval) {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_ess_countdown_one_flag_display), millisecondsTillStart - startPhaseESSOneUpInterval);
|
||||
milisecondsList.add(millisecondsTillStart - startPhaseESSOneUpInterval);
|
||||
result = new Pair<String, List<Object>>(context.getResources().getString(R.string.race_startphase_ess_countdown_one_flag_display), milisecondsList);
|
||||
} else if (millisecondsTillStart < startPhaseESSThreeUpInterval) {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_ess_countdown_two_flag_display), millisecondsTillStart - startPhaseESSTwoUpInterval);
|
||||
milisecondsList.add(millisecondsTillStart - startPhaseESSTwoUpInterval);
|
||||
result = new Pair<String, List<Object>>(context.getResources().getString(R.string.race_startphase_ess_countdown_two_flag_display), milisecondsList);
|
||||
} else if (millisecondsTillStart < startPhaseAPDownInterval) {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_ess_countdown_three_flag_display), millisecondsTillStart - startPhaseESSThreeUpInterval);
|
||||
milisecondsList.add(millisecondsTillStart - startPhaseESSThreeUpInterval);
|
||||
result = new Pair<String, List<Object>>(context.getResources().getString(R.string.race_startphase_ess_countdown_three_flag_display), milisecondsList);
|
||||
} else {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_ess_countdown_ap_flag_removed), millisecondsTillStart - startPhaseAPDownInterval);
|
||||
milisecondsList.add(millisecondsTillStart - startPhaseAPDownInterval);
|
||||
result = new Pair<String, List<Object>>(context.getResources().getString(R.string.race_startphase_ess_countdown_ap_flag_removed), milisecondsList);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+11
-6
@@ -258,16 +258,21 @@ public class GateStartProcedure implements StartProcedure {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<String, Long> getNextFlagCountdownUiLabel(Context context, long millisecondsTillStart) {
|
||||
Pair<String, Long> result;
|
||||
public Pair<String, List<Object>> getNextFlagCountdownUiLabel(Context context, long millisecondsTillStart) {
|
||||
Pair<String, List<Object>> result;
|
||||
List<Object> milisecondsList = new ArrayList<Object>();
|
||||
if (millisecondsTillStart < startPhasePapaDownInterval) {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_gate_class_over_golf_removed), millisecondsTillStart);
|
||||
milisecondsList.add(millisecondsTillStart);
|
||||
result = new Pair<String, List<Object>>(context.getResources().getString(R.string.race_startphase_gate_class_over_golf_removed), milisecondsList);
|
||||
} else if (millisecondsTillStart < startPhasePapaUpInterval) {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_gate_papa_removed), millisecondsTillStart - startPhasePapaDownInterval);
|
||||
milisecondsList.add(millisecondsTillStart - startPhasePapaDownInterval);
|
||||
result = new Pair<String, List<Object>>(context.getResources().getString(R.string.race_startphase_gate_papa_removed), milisecondsList);
|
||||
} else if (millisecondsTillStart < startPhaseClassOverGolfUpIntervall) {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_gate_papa_display), millisecondsTillStart - startPhasePapaUpInterval);
|
||||
milisecondsList.add(millisecondsTillStart - startPhasePapaUpInterval);
|
||||
result = new Pair<String, List<Object>>(context.getResources().getString(R.string.race_startphase_gate_papa_display), milisecondsList);
|
||||
} else {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_gate_class_over_golf_display), millisecondsTillStart - startPhaseClassOverGolfUpIntervall);
|
||||
milisecondsList.add(millisecondsTillStart - startPhaseClassOverGolfUpIntervall);
|
||||
result = new Pair<String, List<Object>>(context.getResources().getString(R.string.race_startphase_gate_class_over_golf_display), milisecondsList);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.sap.sailing.racecommittee.app.domain.startprocedure.impl;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.RunningRaceEventListener;
|
||||
|
||||
public interface RRS26RunningRaceEventListener extends RunningRaceEventListener{
|
||||
|
||||
void onIndividualRecall();
|
||||
|
||||
void onIndividualRecallRemoval();
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.sap.sailing.racecommittee.app.domain.startprocedure.impl;
|
||||
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.StartPhaseEventListener;
|
||||
|
||||
public interface RRS26StartPhaseEventListener extends StartPhaseEventListener{
|
||||
|
||||
void onClassUp();
|
||||
|
||||
void onStartModeUp(Flags startModeFlag);
|
||||
|
||||
void onStartModeDown(Flags startModeFlag);
|
||||
|
||||
void onStartModeFlagChosen(Flags startModeFlag);
|
||||
|
||||
void onClassDown();
|
||||
}
|
||||
+157
-135
@@ -18,9 +18,9 @@ import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEventFactory;
|
||||
import com.sap.sailing.domain.racelog.analyzing.impl.IndividualRecallFinder;
|
||||
import com.sap.sailing.domain.racelog.analyzing.impl.RaceStatusAnalyzer;
|
||||
import com.sap.sailing.domain.racelog.analyzing.impl.StartTimeFinder;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.RunningRaceEventListener;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.StartModeChoosableStartProcedure;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.StartPhaseEventListener;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.StartProcedure;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.StartProcedureListener;
|
||||
@@ -28,54 +28,52 @@ import com.sap.sailing.racecommittee.app.ui.fragments.RaceFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.RRS26RunningRaceFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.startphase.RRS26StartPhaseFragment;
|
||||
|
||||
public class RRS26StartProcedure implements StartProcedure {
|
||||
|
||||
private final static long startPhaseAPDownInterval = 4 * 60 * 1000; // minutes * seconds * milliseconds
|
||||
private final static long startPhaseESSThreeUpInterval = 3 * 60 * 1000; // minutes * seconds * milliseconds
|
||||
private final static long startPhaseESSTwoUpInterval = 2 * 60 * 1000; // minutes * seconds * milliseconds
|
||||
private final static long startPhaseESSOneUpInterval = 1 * 60 * 1000; // minutes * seconds * milliseconds
|
||||
private final static long startPhaseESSOneDownInterval = 0;
|
||||
|
||||
public class RRS26StartProcedure implements StartProcedure, StartModeChoosableStartProcedure {
|
||||
|
||||
private final static long startPhaseClassUpInterval = 5 * 60 * 1000; // minutes * seconds * milliseconds
|
||||
private final static long startPhaseStartModeUpInterval = 4 * 60 * 1000; // minutes * seconds * milliseconds
|
||||
private final static long startPhaseStartModeDownInterval = 1 * 60 * 1000; // minutes * seconds * milliseconds
|
||||
private final static long startPhaseClassDownInterval = 0;
|
||||
|
||||
private final static long individualRecallRemovalInterval = 4 * 60 * 1000; // minutes * seconds * milliseconds
|
||||
|
||||
private final static double essAutomaticRaceFinishMultiplyer = 0.75;
|
||||
|
||||
//list of start procedure specific event id's
|
||||
|
||||
// list of start procedure specific event id's
|
||||
private static final Integer INDIVIDUAL_RECALL_REMOVAL_EVENT_ID = 1;
|
||||
|
||||
|
||||
private List<Long> startProcedureEventIntervals;
|
||||
private RaceLog raceLog;
|
||||
private StartProcedureListener raceStateChangedListener;
|
||||
private EssStartPhaseEventListener startPhaseEventListener;
|
||||
private EssRunningRaceEventListener runningRaceEventListener;
|
||||
|
||||
private RRS26StartPhaseEventListener startPhaseEventListener;
|
||||
private RRS26RunningRaceEventListener runningRaceEventListener;
|
||||
|
||||
private IndividualRecallFinder individualRecallFinder;
|
||||
|
||||
private Flags startModeFlag = Flags.PAPA;
|
||||
private String boatClassName = "";
|
||||
|
||||
public RRS26StartProcedure(RaceLog raceLog) {
|
||||
this.raceLog = raceLog;
|
||||
startProcedureEventIntervals = new ArrayList<Long>();
|
||||
raceStateChangedListener = null;
|
||||
startPhaseEventListener = null;
|
||||
runningRaceEventListener = null;
|
||||
|
||||
startProcedureEventIntervals.add(startPhaseAPDownInterval);
|
||||
startProcedureEventIntervals.add(startPhaseESSThreeUpInterval);
|
||||
startProcedureEventIntervals.add(startPhaseESSTwoUpInterval);
|
||||
startProcedureEventIntervals.add(startPhaseESSOneUpInterval);
|
||||
startProcedureEventIntervals.add(startPhaseESSOneDownInterval);
|
||||
|
||||
individualRecallFinder = new IndividualRecallFinder(raceLog);
|
||||
|
||||
startProcedureEventIntervals.add(startPhaseClassUpInterval);
|
||||
startProcedureEventIntervals.add(startPhaseStartModeUpInterval);
|
||||
startProcedureEventIntervals.add(startPhaseStartModeDownInterval);
|
||||
startProcedureEventIntervals.add(startPhaseClassDownInterval);
|
||||
|
||||
individualRecallFinder = new IndividualRecallFinder(raceLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimePoint getStartPhaseStartTime(TimePoint startTime) {
|
||||
return startTime.minus(startPhaseAPDownInterval);
|
||||
return startTime.minus(startPhaseClassUpInterval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimePoint> getAutomaticEventFireTimePoints(TimePoint startTime) {
|
||||
List<TimePoint> triggerTimePoints = new ArrayList<TimePoint>();
|
||||
|
||||
|
||||
for (Long interval : startProcedureEventIntervals) {
|
||||
triggerTimePoints.add(startTime.minus(interval));
|
||||
}
|
||||
@@ -85,85 +83,73 @@ public class RRS26StartProcedure implements StartProcedure {
|
||||
@Override
|
||||
public void dispatchFiredEventTimePoint(TimePoint startTime, TimePoint eventTime) {
|
||||
long interval = startTime.asMillis() - eventTime.asMillis();
|
||||
|
||||
if (interval == startPhaseAPDownInterval) {
|
||||
handleAPDown(eventTime);
|
||||
} else if (interval == startPhaseESSThreeUpInterval) {
|
||||
handleEssThreeUp(eventTime);
|
||||
} else if (interval == startPhaseESSTwoUpInterval) {
|
||||
handleEssTwoUpAndEssThreeDown(eventTime);
|
||||
} else if (interval == startPhaseESSOneUpInterval) {
|
||||
handleEssOneUpAndEssTwoDown(eventTime);
|
||||
} else if (interval == startPhaseESSOneDownInterval) {
|
||||
handleEssOneDown(eventTime);
|
||||
|
||||
if (interval == startPhaseClassUpInterval) {
|
||||
handleClassUp(eventTime);
|
||||
} else if (interval == startPhaseStartModeUpInterval) {
|
||||
handleStartRuleUp(eventTime);
|
||||
} else if (interval == startPhaseStartModeDownInterval) {
|
||||
handleStartRuleDown(eventTime);
|
||||
} else if (interval == startPhaseClassDownInterval) {
|
||||
handleClassDown(eventTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAPDown(TimePoint eventTime) {
|
||||
|
||||
private void handleClassUp(TimePoint eventTime) {
|
||||
|
||||
if (raceStateChangedListener != null) {
|
||||
raceStateChangedListener.onRaceStartphaseEntered(eventTime);
|
||||
}
|
||||
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(), Collections.<Competitor>emptyList(),
|
||||
raceLog.getCurrentPassId(), Flags.AP, Flags.NONE, /*isDisplayed*/false);
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(),
|
||||
Collections.<Competitor> emptyList(), raceLog.getCurrentPassId(), Flags.CLASS, Flags.NONE, /* isDisplayed */
|
||||
true);
|
||||
raceLog.add(event);
|
||||
|
||||
|
||||
if (startPhaseEventListener != null) {
|
||||
startPhaseEventListener.onAPDown();
|
||||
startPhaseEventListener.onClassUp();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEssThreeUp(TimePoint eventTime) {
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(), Collections.<Competitor>emptyList(),
|
||||
raceLog.getCurrentPassId(), Flags.ESSTHREE, Flags.NONE, /*isDisplayed*/true);
|
||||
private void handleStartRuleUp(TimePoint eventTime) {
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(),
|
||||
Collections.<Competitor> emptyList(), raceLog.getCurrentPassId(), this.startModeFlag, Flags.NONE, /* isDisplayed */
|
||||
true);
|
||||
raceLog.add(event);
|
||||
|
||||
|
||||
if (startPhaseEventListener != null) {
|
||||
startPhaseEventListener.onEssThreeUp();
|
||||
startPhaseEventListener.onStartModeUp(this.startModeFlag);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEssTwoUpAndEssThreeDown(TimePoint eventTime) {
|
||||
|
||||
RaceLogEvent essThreeDownEvent = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(), Collections.<Competitor>emptyList(),
|
||||
raceLog.getCurrentPassId(), Flags.ESSTHREE, Flags.NONE, /*isDisplayed*/false);
|
||||
raceLog.add(essThreeDownEvent);
|
||||
|
||||
RaceLogEvent essTwoUpEvent = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(), Collections.<Competitor>emptyList(),
|
||||
raceLog.getCurrentPassId(), Flags.ESSTWO, Flags.NONE, /*isDisplayed*/true);
|
||||
raceLog.add(essTwoUpEvent);
|
||||
|
||||
private void handleStartRuleDown(TimePoint eventTime) {
|
||||
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(),
|
||||
Collections.<Competitor> emptyList(), raceLog.getCurrentPassId(), this.startModeFlag, Flags.NONE, /* isDisplayed */
|
||||
false);
|
||||
raceLog.add(event);
|
||||
|
||||
if (startPhaseEventListener != null) {
|
||||
startPhaseEventListener.onEssTwoUp();
|
||||
startPhaseEventListener.onStartModeUp(this.startModeFlag);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEssOneUpAndEssTwoDown(TimePoint eventTime) {
|
||||
|
||||
RaceLogEvent essTwoDownEvent = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(), Collections.<Competitor>emptyList(),
|
||||
raceLog.getCurrentPassId(), Flags.ESSTWO, Flags.NONE, /*isDisplayed*/false);
|
||||
raceLog.add(essTwoDownEvent);
|
||||
|
||||
RaceLogEvent essOneUpEvent = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(), Collections.<Competitor>emptyList(),
|
||||
raceLog.getCurrentPassId(), Flags.ESSONE, Flags.NONE, /*isDisplayed*/true);
|
||||
raceLog.add(essOneUpEvent);
|
||||
|
||||
if (startPhaseEventListener != null) {
|
||||
startPhaseEventListener.onEssOneUp();
|
||||
}
|
||||
}
|
||||
private void handleClassDown(TimePoint eventTime) {
|
||||
|
||||
private void handleEssOneDown(TimePoint eventTime) {
|
||||
RaceLogEvent essOneDownEvent = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(), Collections.<Competitor>emptyList(),
|
||||
raceLog.getCurrentPassId(), Flags.ESSONE, Flags.NONE, /*isDisplayed*/false);
|
||||
raceLog.add(essOneDownEvent);
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(),
|
||||
Collections.<Competitor> emptyList(), raceLog.getCurrentPassId(), Flags.CLASS, Flags.NONE, /* isDisplayed */
|
||||
false);
|
||||
raceLog.add(event);
|
||||
|
||||
if (startPhaseEventListener != null) {
|
||||
startPhaseEventListener.onClassDown();
|
||||
}
|
||||
|
||||
if (raceStateChangedListener != null) {
|
||||
raceStateChangedListener.onRaceStarted(eventTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setStartProcedureListener(StartProcedureListener raceStateChangedListener) {
|
||||
this.raceStateChangedListener = raceStateChangedListener;
|
||||
@@ -181,40 +167,37 @@ public class RRS26StartProcedure implements StartProcedure {
|
||||
} else {
|
||||
resultTime = now;
|
||||
}
|
||||
|
||||
|
||||
return resultTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinishing(TimePoint eventTime) {
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(), Collections.<Competitor>emptyList(),
|
||||
raceLog.getCurrentPassId(), Flags.BLUE, Flags.NONE, /*isDisplayed*/true);
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(),
|
||||
Collections.<Competitor> emptyList(), raceLog.getCurrentPassId(), Flags.BLUE, Flags.NONE, /* isDisplayed */
|
||||
true);
|
||||
raceLog.add(event);
|
||||
|
||||
StartTimeFinder startTimeFinder = new StartTimeFinder(raceLog);
|
||||
long raceDuration = eventTime.asMillis()-startTimeFinder.getStartTime().asMillis();
|
||||
|
||||
TimePoint automaticRaceEnd = eventTime.plus((long) (raceDuration*essAutomaticRaceFinishMultiplyer));
|
||||
|
||||
|
||||
if (raceStateChangedListener != null) {
|
||||
raceStateChangedListener.onRaceFinishing(eventTime, automaticRaceEnd);
|
||||
raceStateChangedListener.onRaceFinishing(eventTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dispatchAutomaticRaceEndEvent(TimePoint automaticRaceEnd) {
|
||||
RaceStatusAnalyzer analyzer = new RaceStatusAnalyzer(raceLog);
|
||||
if(analyzer.getStatus().equals(RaceLogRaceStatus.FINISHING)) {
|
||||
//setFinished(automaticRaceEnd);
|
||||
if (analyzer.getStatus().equals(RaceLogRaceStatus.FINISHING)) {
|
||||
// setFinished(automaticRaceEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished(TimePoint eventTime) {
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(), Collections.<Competitor>emptyList(),
|
||||
raceLog.getCurrentPassId(), Flags.BLUE, Flags.NONE, /*isDisplayed*/false);
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(),
|
||||
Collections.<Competitor> emptyList(), raceLog.getCurrentPassId(), Flags.BLUE, Flags.NONE, /* isDisplayed */
|
||||
false);
|
||||
raceLog.add(event);
|
||||
|
||||
|
||||
if (raceStateChangedListener != null) {
|
||||
raceStateChangedListener.onRaceFinished(eventTime);
|
||||
}
|
||||
@@ -234,10 +217,11 @@ public class RRS26StartProcedure implements StartProcedure {
|
||||
}
|
||||
|
||||
private void handleAPUp(TimePoint eventTime, Flags lowerFlag) {
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(), Collections.<Competitor>emptyList(),
|
||||
raceLog.getCurrentPassId(), Flags.AP, lowerFlag, /*isDisplayed*/true);
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(),
|
||||
Collections.<Competitor> emptyList(), raceLog.getCurrentPassId(), Flags.AP, lowerFlag, /* isDisplayed */
|
||||
true);
|
||||
raceLog.add(event);
|
||||
|
||||
|
||||
if (raceStateChangedListener != null) {
|
||||
raceStateChangedListener.onRaceAborted(eventTime);
|
||||
}
|
||||
@@ -257,10 +241,11 @@ public class RRS26StartProcedure implements StartProcedure {
|
||||
}
|
||||
|
||||
private void handleNovemberUp(TimePoint eventTime, Flags lowerFlag) {
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(), Collections.<Competitor>emptyList(),
|
||||
raceLog.getCurrentPassId(), Flags.NOVEMBER, lowerFlag, /*isDisplayed*/true);
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(),
|
||||
Collections.<Competitor> emptyList(), raceLog.getCurrentPassId(), Flags.NOVEMBER, lowerFlag, /* isDisplayed */
|
||||
true);
|
||||
raceLog.add(event);
|
||||
|
||||
|
||||
if (raceStateChangedListener != null) {
|
||||
raceStateChangedListener.onRaceAborted(eventTime);
|
||||
}
|
||||
@@ -268,29 +253,31 @@ public class RRS26StartProcedure implements StartProcedure {
|
||||
|
||||
@Override
|
||||
public void setGeneralRecall(TimePoint eventTime) {
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(), Collections.<Competitor>emptyList(),
|
||||
raceLog.getCurrentPassId(), Flags.FIRSTSUBSTITUTE, Flags.NONE, /*isDisplayed*/true);
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(),
|
||||
Collections.<Competitor> emptyList(), raceLog.getCurrentPassId(), Flags.FIRSTSUBSTITUTE, Flags.NONE, /* isDisplayed */
|
||||
true);
|
||||
raceLog.add(event);
|
||||
|
||||
|
||||
if (raceStateChangedListener != null) {
|
||||
raceStateChangedListener.onRaceAborted(eventTime);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIndividualRecall(TimePoint eventTime) {
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(), Collections.<Competitor>emptyList(),
|
||||
raceLog.getCurrentPassId(), Flags.XRAY, Flags.NONE, /*isDisplayed*/true);
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createFlagEvent(eventTime, UUID.randomUUID(),
|
||||
Collections.<Competitor> emptyList(), raceLog.getCurrentPassId(), Flags.XRAY, Flags.NONE, /* isDisplayed */
|
||||
true);
|
||||
raceLog.add(event);
|
||||
|
||||
|
||||
TimePoint individualRecallRemovalFireTimePoint = eventTime.plus(individualRecallRemovalInterval);
|
||||
|
||||
|
||||
|
||||
if (runningRaceEventListener != null) {
|
||||
runningRaceEventListener.onIndividualRecall();
|
||||
}
|
||||
|
||||
|
||||
if (raceStateChangedListener != null) {
|
||||
raceStateChangedListener.onStartProcedureSpecificEvent(individualRecallRemovalFireTimePoint, INDIVIDUAL_RECALL_REMOVAL_EVENT_ID);
|
||||
raceStateChangedListener.onStartProcedureSpecificEvent(individualRecallRemovalFireTimePoint,
|
||||
INDIVIDUAL_RECALL_REMOVAL_EVENT_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,24 +293,25 @@ public class RRS26StartProcedure implements StartProcedure {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean getIndividualRecallDisplayed() {
|
||||
if(this.individualRecallFinder.getIndividualRecallDisplayedTime()!=null){
|
||||
if(this.individualRecallFinder.getIndividualRecallDisplayedRemovalTime()!=null){
|
||||
if(this.individualRecallFinder.getIndividualRecallDisplayedRemovalTime().after(this.individualRecallFinder.getIndividualRecallDisplayedTime())){
|
||||
if (this.individualRecallFinder.getIndividualRecallDisplayedTime() != null) {
|
||||
if (this.individualRecallFinder.getIndividualRecallDisplayedRemovalTime() != null) {
|
||||
if (this.individualRecallFinder.getIndividualRecallDisplayedRemovalTime().after(
|
||||
this.individualRecallFinder.getIndividualRecallDisplayedTime())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends RaceFragment> getStartphaseFragment() {
|
||||
return RRS26StartPhaseFragment.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<? extends RaceFragment> getRunningRaceFragment() {
|
||||
return RRS26RunningRaceFragment.class;
|
||||
@@ -331,37 +319,71 @@ public class RRS26StartProcedure implements StartProcedure {
|
||||
|
||||
@Override
|
||||
public void setStartPhaseEventListener(StartPhaseEventListener listener) {
|
||||
startPhaseEventListener = (EssStartPhaseEventListener) listener;
|
||||
startPhaseEventListener = (RRS26StartPhaseEventListener) listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<String, Long> getNextFlagCountdownUiLabel(Context context, long millisecondsTillStart) {
|
||||
Pair<String, Long> result;
|
||||
if (millisecondsTillStart < startPhaseESSOneUpInterval) {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_ess_countdown_one_flag_remove), millisecondsTillStart);
|
||||
} else if (millisecondsTillStart < startPhaseESSTwoUpInterval) {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_ess_countdown_one_flag_display), millisecondsTillStart - startPhaseESSOneUpInterval);
|
||||
} else if (millisecondsTillStart < startPhaseESSThreeUpInterval) {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_ess_countdown_two_flag_display), millisecondsTillStart - startPhaseESSTwoUpInterval);
|
||||
} else if (millisecondsTillStart < startPhaseAPDownInterval) {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_ess_countdown_three_flag_display), millisecondsTillStart - startPhaseESSThreeUpInterval);
|
||||
public Pair<String, List<Object>> getNextFlagCountdownUiLabel(Context context, long millisecondsTillStart) {
|
||||
Pair<String, List<Object>> result;
|
||||
List<Object> milisecondsList = new ArrayList<Object>();
|
||||
if (millisecondsTillStart < startPhaseStartModeDownInterval) {
|
||||
milisecondsList.add(millisecondsTillStart);
|
||||
milisecondsList.add(this.boatClassName);
|
||||
result = new Pair<String, List<Object>>(context.getResources().getString(
|
||||
R.string.race_startphase_countdown_class_remove), milisecondsList);
|
||||
} else if (millisecondsTillStart < startPhaseStartModeUpInterval) {
|
||||
milisecondsList.add(millisecondsTillStart - startPhaseStartModeDownInterval);
|
||||
milisecondsList.add(this.startModeFlag.toString());
|
||||
result = new Pair<String, List<Object>>(context.getResources().getString(
|
||||
R.string.race_startphase_countdown_mode_remove), milisecondsList);
|
||||
} else if (millisecondsTillStart < startPhaseClassUpInterval) {
|
||||
milisecondsList.add(millisecondsTillStart - startPhaseStartModeUpInterval);
|
||||
milisecondsList.add(this.startModeFlag.toString());
|
||||
result = new Pair<String, List<Object>>(context.getResources().getString(
|
||||
R.string.race_startphase_countdown_mode_display), milisecondsList);
|
||||
} else {
|
||||
result = new Pair<String, Long>(context.getResources().getString(R.string.race_startphase_ess_countdown_ap_flag_removed), millisecondsTillStart - startPhaseAPDownInterval);
|
||||
milisecondsList.add(millisecondsTillStart - startPhaseClassUpInterval);
|
||||
milisecondsList.add(this.boatClassName);
|
||||
result = new Pair<String, List<Object>>(context.getResources().getString(
|
||||
R.string.race_startphase_countdown_class_display), milisecondsList);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRunningRaceEventListener(RunningRaceEventListener listener) {
|
||||
this.runningRaceEventListener = (EssRunningRaceEventListener) listener;
|
||||
|
||||
this.runningRaceEventListener = (RRS26RunningRaceEventListener) listener;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleStartProcedureSpecificEvent(TimePoint eventTime, Integer eventId) {
|
||||
if(eventId.equals(INDIVIDUAL_RECALL_REMOVAL_EVENT_ID)){
|
||||
if (eventId.equals(INDIVIDUAL_RECALL_REMOVAL_EVENT_ID)) {
|
||||
setIndividualRecallRemoval(eventTime);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartModeFlag(Flags startModeFlag) {
|
||||
this.startModeFlag = startModeFlag;
|
||||
startPhaseEventListener.onStartModeFlagChosen(startModeFlag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flags getCurrentStartModeFlag() {
|
||||
return this.startModeFlag;
|
||||
}
|
||||
|
||||
public boolean isIndividualRecallDisplayed() {
|
||||
if(this.individualRecallFinder.getIndividualRecallDisplayedTime() != null){
|
||||
if(this.individualRecallFinder.getIndividualRecallDisplayedRemovalTime() != null){
|
||||
if(this.individualRecallFinder.getIndividualRecallDisplayedRemovalTime().after(this.individualRecallFinder.getIndividualRecallDisplayedTime())){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -10,10 +10,11 @@ public class StartProcedureFactory {
|
||||
switch (type) {
|
||||
case ESS:
|
||||
return new ExtremeSailingSeriesStartProcedure(raceLog);
|
||||
case GateStart:
|
||||
//commented out for safety reasons
|
||||
/*case GateStart:
|
||||
return new GateStartProcedure(raceLog);
|
||||
case RRS26:
|
||||
return new RRS26StartProcedure(raceLog);
|
||||
return new RRS26StartProcedure(raceLog);*/
|
||||
default:
|
||||
throw new UnsupportedOperationException("Not yet implemented start procedure.");
|
||||
}
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.dialogs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.StartModeChoosableStartProcedure;
|
||||
|
||||
public class RaceChooseStartModeDialog extends RaceDialogFragment {
|
||||
|
||||
public interface StartModeSelectionListener {
|
||||
public void onStartModeSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.race_choose_start_mode_view, container);
|
||||
getDialog().setTitle(getText(R.string.choose_startmode));
|
||||
|
||||
return view;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
ImageButton papaButton = (ImageButton) getView().findViewById(R.id.papaFlagButton);
|
||||
ImageButton zuluButton = (ImageButton) getView().findViewById(R.id.zuluFlagButton);
|
||||
ImageButton blackButton = (ImageButton) getView().findViewById(R.id.blackFlagButton);
|
||||
ImageButton indiaButton = (ImageButton) getView().findViewById(R.id.indiaFlagButton);
|
||||
|
||||
papaButton.setOnClickListener(new OnClickListener() {
|
||||
|
||||
public void onClick(View arg0) {
|
||||
process(Flags.PAPA);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
zuluButton.setOnClickListener(new OnClickListener() {
|
||||
|
||||
public void onClick(View arg0) {
|
||||
process(Flags.ZULU);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
blackButton.setOnClickListener(new OnClickListener() {
|
||||
|
||||
public void onClick(View arg0) {
|
||||
process(Flags.BLACK);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
indiaButton.setOnClickListener(new OnClickListener() {
|
||||
|
||||
public void onClick(View arg0) {
|
||||
process(Flags.INDIA);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void process(Flags flag) {
|
||||
StartModeChoosableStartProcedure startProcedure = (StartModeChoosableStartProcedure) this.getRace().getState().getStartProcedure();
|
||||
startProcedure.setStartModeFlag(flag);
|
||||
this.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyTick() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -17,14 +17,14 @@ import android.widget.TextView;
|
||||
import com.sap.sailing.domain.base.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.impl.EssRunningRaceEventListener;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.impl.ExtremeSailingSeriesStartProcedure;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.impl.RRS26RunningRaceEventListener;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.impl.RRS26StartProcedure;
|
||||
import com.sap.sailing.racecommittee.app.logging.ExLog;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.RaceFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.dialogs.AbortTypeSelectionDialog;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.dialogs.RaceDialogFragment;
|
||||
|
||||
public class RRS26RunningRaceFragment extends RaceFragment implements EssRunningRaceEventListener {
|
||||
public class RRS26RunningRaceFragment extends RaceFragment implements RRS26RunningRaceEventListener {
|
||||
|
||||
private TextView countUpTextView;
|
||||
private ImageView individualRecallFlag;
|
||||
@@ -71,12 +71,12 @@ public class RRS26RunningRaceFragment extends RaceFragment implements EssRunning
|
||||
individualRecallButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
TimePoint now = MillisecondsTimePoint.now();
|
||||
if (getRace().getState().getStartProcedure() instanceof ExtremeSailingSeriesStartProcedure) {
|
||||
ExtremeSailingSeriesStartProcedure essStartProcedure = ((ExtremeSailingSeriesStartProcedure) getRace().getState().getStartProcedure());
|
||||
if (essStartProcedure.isIndividualRecallDisplayed()) {
|
||||
essStartProcedure.setIndividualRecallRemoval(now);
|
||||
if (getRace().getState().getStartProcedure() instanceof RRS26StartProcedure) {
|
||||
RRS26StartProcedure rrs26StartProcedure = ((RRS26StartProcedure) getRace().getState().getStartProcedure());
|
||||
if (rrs26StartProcedure.isIndividualRecallDisplayed()) {
|
||||
rrs26StartProcedure.setIndividualRecallRemoval(now);
|
||||
} else {
|
||||
essStartProcedure.setIndividualRecall(now);
|
||||
rrs26StartProcedure.setIndividualRecall(now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.startphase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentManager;
|
||||
import android.os.Bundle;
|
||||
@@ -152,9 +154,9 @@ public class EssStartPhaseFragment extends RaceFragment implements EssStartPhase
|
||||
}
|
||||
|
||||
private void setNextFlagCountdownLabel(long millisecondsTillStart) {
|
||||
Pair<String, Long> countDownPair = getRace().getState().getStartProcedure().getNextFlagCountdownUiLabel(getActivity(), millisecondsTillStart);
|
||||
nextFlagCountdown.setText(String.format(countDownPair.getA(),
|
||||
TimeUtils.prettyString(countDownPair.getB().longValue())));
|
||||
Pair<String, List<Object>> countdownStringPackage = getRace().getState().getStartProcedure().getNextFlagCountdownUiLabel(getActivity(), millisecondsTillStart);
|
||||
nextFlagCountdown.setText(String.format(countdownStringPackage.getA(),
|
||||
TimeUtils.prettyString(((Number) countdownStringPackage.getB().get(0)).longValue())));
|
||||
}
|
||||
|
||||
protected void showAPModeDialog() {
|
||||
|
||||
+5
-3
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.startphase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentManager;
|
||||
import android.os.Bundle;
|
||||
@@ -201,9 +203,9 @@ public class GateStartPhaseFragment extends RaceFragment implements GateStartPha
|
||||
}
|
||||
|
||||
private void setNextFlagCountdownLabel(long millisecondsTillStart) {
|
||||
Pair<String, Long> countDownPair = getRace().getState().getStartProcedure().getNextFlagCountdownUiLabel(getActivity(), millisecondsTillStart);
|
||||
nextFlagCountdown.setText(String.format(countDownPair.getA(),
|
||||
TimeUtils.prettyString(countDownPair.getB().longValue())));
|
||||
Pair<String, List<Object>> countdownStringPackage = getRace().getState().getStartProcedure().getNextFlagCountdownUiLabel(getActivity(), millisecondsTillStart);
|
||||
nextFlagCountdown.setText(String.format(countdownStringPackage.getA(),
|
||||
TimeUtils.prettyString(((Number) countdownStringPackage.getB().get(0)).longValue())));
|
||||
}
|
||||
|
||||
protected void showAPModeDialog() {
|
||||
|
||||
+143
-68
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.startphase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentManager;
|
||||
import android.os.Bundle;
|
||||
@@ -12,32 +14,36 @@ import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.sap.sailing.domain.base.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogFlagEvent;
|
||||
import com.sap.sailing.domain.racelog.analyzing.impl.LastFlagFinder;
|
||||
import com.sap.sailing.racecommittee.app.AppConstants;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.impl.EssStartPhaseEventListener;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.StartModeChoosableStartProcedure;
|
||||
import com.sap.sailing.racecommittee.app.domain.startprocedure.impl.RRS26StartPhaseEventListener;
|
||||
import com.sap.sailing.racecommittee.app.logging.ExLog;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.RaceFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.dialogs.AbortModeSelectionDialog;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.dialogs.RaceChooseStartModeDialog;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.dialogs.RaceDialogFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.RaceInfoListener;
|
||||
import com.sap.sailing.racecommittee.app.utils.TimeUtils;
|
||||
|
||||
public class RRS26StartPhaseFragment extends RaceFragment implements EssStartPhaseEventListener {
|
||||
public class RRS26StartPhaseFragment extends RaceFragment implements RRS26StartPhaseEventListener {
|
||||
|
||||
private RaceInfoListener infoListener;
|
||||
|
||||
|
||||
TextView raceCountdown;
|
||||
TextView nextFlagCountdown;
|
||||
TextView startModeButtonLabel;
|
||||
ImageButton startModeButton;
|
||||
ImageButton abortingFlagButton;
|
||||
ImageView displayedFlag;
|
||||
ImageView nextToBeDisplayedFlag;
|
||||
ImageView classFlagUp;
|
||||
ImageView startModeFlagUp;
|
||||
ImageView classFlagDown;
|
||||
ImageView startModeFlagDown;
|
||||
Button resetTimeButton;
|
||||
|
||||
@Override
|
||||
@@ -47,9 +53,7 @@ public class RRS26StartPhaseFragment extends RaceFragment implements EssStartPha
|
||||
if (activity instanceof RaceInfoListener) {
|
||||
this.infoListener = (RaceInfoListener) activity;
|
||||
} else {
|
||||
throw new UnsupportedOperationException(String.format(
|
||||
"%s must implement %s",
|
||||
activity,
|
||||
throw new UnsupportedOperationException(String.format("%s must implement %s", activity,
|
||||
RaceInfoListener.class.getName()));
|
||||
}
|
||||
}
|
||||
@@ -58,18 +62,29 @@ public class RRS26StartPhaseFragment extends RaceFragment implements EssStartPha
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.race_startphase_rrs26_view, container, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
raceCountdown = (TextView) getView().findViewById(R.id.raceCountdown);
|
||||
nextFlagCountdown = (TextView) getView().findViewById(R.id.nextFlagCountdown);
|
||||
displayedFlag = (ImageView) getView().findViewById(R.id.currentlyDisplayedFlag);
|
||||
nextToBeDisplayedFlag = (ImageView) getView().findViewById(R.id.nextFlagToBeDisplayed);
|
||||
classFlagUp = (ImageView) getView().findViewById(R.id.classFlagUp);
|
||||
startModeFlagUp = (ImageView) getView().findViewById(R.id.startModeFlagUp);
|
||||
classFlagDown = (ImageView) getView().findViewById(R.id.classFlagDown);
|
||||
startModeFlagDown = (ImageView) getView().findViewById(R.id.startModeFlagDown);
|
||||
|
||||
ExLog.i("STARTPHASE", "" + getRace().getId() + " " + getRace().getStatus().toString());
|
||||
|
||||
startModeButton = (ImageButton) getView().findViewById(R.id.startModeButton);
|
||||
startModeButtonLabel = (TextView) getView().findViewById(R.id.startModeButtonLabel);
|
||||
startModeButton.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showStartModeDialog();
|
||||
}
|
||||
});
|
||||
|
||||
abortingFlagButton = (ImageButton) getView().findViewById(R.id.abortingFlagButton);
|
||||
abortingFlagButton.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@@ -85,50 +100,62 @@ public class RRS26StartPhaseFragment extends RaceFragment implements EssStartPha
|
||||
infoListener.onResetTime();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setupUi();
|
||||
}
|
||||
|
||||
private void setupUi() {
|
||||
RaceLog log = getRace().getState().getRaceLog();
|
||||
log.lockForRead();
|
||||
try {
|
||||
RaceLogEvent lastEvent = log.getLastFixAtOrBefore(MillisecondsTimePoint.now());
|
||||
// TODO: better analysis of state. only flagevents... sort by timestamp...
|
||||
if (lastEvent instanceof RaceLogFlagEvent) {
|
||||
RaceLogFlagEvent flagEvent = (RaceLogFlagEvent) lastEvent;
|
||||
Flags flag = flagEvent.getUpperFlag();
|
||||
|
||||
if (!flagEvent.isDisplayed() && flag.equals(Flags.AP)) {
|
||||
onAPDown();
|
||||
} else if (flagEvent.isDisplayed() && flag.equals(Flags.ESSTHREE)) {
|
||||
onEssThreeUp();
|
||||
} else if ((!flagEvent.isDisplayed() && flag.equals(Flags.ESSTHREE)) ||
|
||||
(flagEvent.isDisplayed() && flag.equals(Flags.ESSTWO))) {
|
||||
onEssTwoUp();
|
||||
} else if ((!flagEvent.isDisplayed() && flag.equals(Flags.ESSTWO)) ||
|
||||
(flagEvent.isDisplayed() && flag.equals(Flags.ESSONE))) {
|
||||
onEssOneUp();
|
||||
StartModeChoosableStartProcedure startProcedure = (StartModeChoosableStartProcedure) this.getRace().getState().getStartProcedure();
|
||||
this.onStartModeFlagChosen(startProcedure.getCurrentStartModeFlag());
|
||||
LastFlagFinder lastFlagFinder = new LastFlagFinder(this.getRace().getRaceLog());
|
||||
RaceLogFlagEvent lastFlagEvent = lastFlagFinder.getLastFlagEvent();
|
||||
if(lastFlagEvent != null){
|
||||
if(lastFlagEvent.getUpperFlag().equals(Flags.CLASS) && lastFlagEvent.isDisplayed()){
|
||||
this.onClassUp();
|
||||
} else if(lastFlagEvent.getUpperFlag().equals(Flags.PAPA)){
|
||||
if(lastFlagEvent.isDisplayed()){
|
||||
onStartModeUp(lastFlagEvent.getUpperFlag());
|
||||
} else {
|
||||
onStartModeDown(lastFlagEvent.getUpperFlag());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
log.unlockAfterRead();
|
||||
} else if(lastFlagEvent.getUpperFlag().equals(Flags.ZULU)){
|
||||
if(lastFlagEvent.isDisplayed()){
|
||||
onStartModeUp(lastFlagEvent.getUpperFlag());
|
||||
} else {
|
||||
onStartModeDown(lastFlagEvent.getUpperFlag());
|
||||
}
|
||||
} else if(lastFlagEvent.getUpperFlag().equals(Flags.INDIA)){
|
||||
if(lastFlagEvent.isDisplayed()){
|
||||
onStartModeUp(lastFlagEvent.getUpperFlag());
|
||||
} else {
|
||||
onStartModeDown(lastFlagEvent.getUpperFlag());
|
||||
}
|
||||
} else if(lastFlagEvent.getUpperFlag().equals(Flags.BLACK)){
|
||||
if(lastFlagEvent.isDisplayed()){
|
||||
onStartModeUp(lastFlagEvent.getUpperFlag());
|
||||
} else {
|
||||
onStartModeDown(lastFlagEvent.getUpperFlag());
|
||||
}
|
||||
} else if(lastFlagEvent.getUpperFlag().equals(Flags.CLASS) && !lastFlagEvent.isDisplayed()){
|
||||
onClassDown();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
|
||||
getRace().getState().getStartProcedure().setStartPhaseEventListener(this);
|
||||
ExLog.w(RRS26StartPhaseFragment.class.getName(), String.format("Fragment %s is now shown", RRS26StartPhaseFragment.class.getName()));
|
||||
ExLog.w(RRS26StartPhaseFragment.class.getName(),
|
||||
String.format("Fragment %s is now shown", RRS26StartPhaseFragment.class.getName()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
|
||||
getRace().getState().getStartProcedure().setStartPhaseEventListener(null);
|
||||
}
|
||||
|
||||
@@ -139,22 +166,24 @@ public class RRS26StartPhaseFragment extends RaceFragment implements EssStartPha
|
||||
setCountdownLabels(TimeUtils.timeUntil(startTime));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setCountdownLabels(long millisecondsTillStart) {
|
||||
setStarttimeCountdownLabel(millisecondsTillStart);
|
||||
setNextFlagCountdownLabel(millisecondsTillStart);
|
||||
}
|
||||
|
||||
private void setStarttimeCountdownLabel(long millisecondsTillStart) {
|
||||
raceCountdown.setText(String.format(
|
||||
getString(R.string.race_startphase_countdown_start),
|
||||
raceCountdown.setText(String.format(getString(R.string.race_startphase_countdown_start),
|
||||
TimeUtils.prettyString(millisecondsTillStart), getRace().getName()));
|
||||
}
|
||||
|
||||
private void setNextFlagCountdownLabel(long millisecondsTillStart) {
|
||||
Pair<String, Long> countDownPair = getRace().getState().getStartProcedure().getNextFlagCountdownUiLabel(getActivity(), millisecondsTillStart);
|
||||
nextFlagCountdown.setText(String.format(countDownPair.getA(),
|
||||
TimeUtils.prettyString(countDownPair.getB().longValue())));
|
||||
Pair<String, List<Object>> countdownStringPackage = getRace().getState().getStartProcedure()
|
||||
.getNextFlagCountdownUiLabel(getActivity(), millisecondsTillStart);
|
||||
CharSequence countdownTime = TimeUtils
|
||||
.prettyString(((Number) countdownStringPackage.getB().get(0)).longValue());
|
||||
String countDownMetaInfo = (String) countdownStringPackage.getB().get(1);
|
||||
nextFlagCountdown.setText(String.format(countdownStringPackage.getA(), countdownTime, countDownMetaInfo));
|
||||
}
|
||||
|
||||
protected void showAPModeDialog() {
|
||||
@@ -169,33 +198,79 @@ public class RRS26StartPhaseFragment extends RaceFragment implements EssStartPha
|
||||
fragment.show(fragmentManager, "dialogAPMode");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAPDown() {
|
||||
displayedFlag.setVisibility(View.INVISIBLE);
|
||||
protected void showStartModeDialog() {
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
|
||||
RaceDialogFragment fragment = new RaceChooseStartModeDialog();
|
||||
|
||||
resetTimeButton.setEnabled(false);
|
||||
resetTimeButton.setVisibility(View.GONE);
|
||||
Bundle args = getRecentArguments();
|
||||
fragment.setArguments(args);
|
||||
|
||||
fragment.show(fragmentManager, "dialogStartMode");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEssThreeUp() {
|
||||
displayedFlag.setVisibility(View.VISIBLE);
|
||||
displayedFlag.setImageResource(R.drawable.three_min_flag);
|
||||
|
||||
nextToBeDisplayedFlag.setImageResource(R.drawable.two_min_flag);
|
||||
public void onClassUp() {
|
||||
classFlagUp.setVisibility(View.VISIBLE);
|
||||
startModeFlagUp.setVisibility(View.GONE);
|
||||
classFlagDown.setVisibility(View.GONE);
|
||||
startModeFlagDown.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEssTwoUp() {
|
||||
displayedFlag.setImageResource(R.drawable.two_min_flag);
|
||||
|
||||
nextToBeDisplayedFlag.setImageResource(R.drawable.one_min_flag);
|
||||
public void onStartModeUp(Flags startModeFlag) {
|
||||
hideStartModeButton();
|
||||
setStartModeFlags(startModeFlag);
|
||||
classFlagUp.setVisibility(View.VISIBLE);
|
||||
startModeFlagUp.setVisibility(View.VISIBLE);
|
||||
classFlagDown.setVisibility(View.GONE);
|
||||
startModeFlagDown.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEssOneUp() {
|
||||
displayedFlag.setImageResource(R.drawable.one_min_flag);
|
||||
|
||||
nextToBeDisplayedFlag.setVisibility(View.INVISIBLE);
|
||||
public void onStartModeDown(Flags startModeFlag) {
|
||||
hideStartModeButton();
|
||||
setStartModeFlags(startModeFlag);
|
||||
classFlagUp.setVisibility(View.VISIBLE);
|
||||
startModeFlagUp.setVisibility(View.GONE);
|
||||
classFlagDown.setVisibility(View.GONE);
|
||||
startModeFlagDown.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClassDown() {
|
||||
hideStartModeButton();
|
||||
classFlagUp.setVisibility(View.GONE);
|
||||
startModeFlagUp.setVisibility(View.GONE);
|
||||
classFlagDown.setVisibility(View.VISIBLE);
|
||||
startModeFlagDown.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void hideStartModeButton() {
|
||||
startModeButton.setVisibility(View.GONE);
|
||||
startModeButtonLabel.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void setStartModeFlags(Flags startModeFlag) {
|
||||
if(startModeFlag.equals(Flags.PAPA)){
|
||||
startModeFlagDown.setImageResource(R.drawable.papa_flag);
|
||||
startModeFlagUp.setImageResource(R.drawable.papa_flag);
|
||||
} else if(startModeFlag.equals(Flags.ZULU)){
|
||||
startModeFlagDown.setImageResource(R.drawable.zulu_flag);
|
||||
startModeFlagUp.setImageResource(R.drawable.zulu_flag);
|
||||
} else if(startModeFlag.equals(Flags.INDIA)){
|
||||
startModeFlagDown.setImageResource(R.drawable.india_flag);
|
||||
startModeFlagUp.setImageResource(R.drawable.india_flag);
|
||||
} else if(startModeFlag.equals(Flags.BLACK)){
|
||||
startModeFlagDown.setImageResource(R.drawable.black_flag);
|
||||
startModeFlagUp.setImageResource(R.drawable.black_flag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartModeFlagChosen(Flags startModeFlag) {
|
||||
setStartModeFlags(startModeFlag);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user