From 3f925201256f0d33db1cf62a55d0261b5583c7c4 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Sat, 29 Apr 2017 09:29:01 +0200 Subject: [PATCH] only CR/LF changes due to git config change Change-Id: I0a8649611c2ed63c772b9c37ad89b88eed5a4e96 --- .../src/net/sf/marineapi/nmea/util/Side.java | 130 ++--- .../net/sf/marineapi/nmea/util/package.html | 12 +- .../marineapi/provider/HeadingProvider.java | 160 +++--- .../provider/event/HeadingEvent.java | 144 ++--- .../provider/event/HeadingListener.java | 74 +-- .../sf/marineapi/provider/event/package.html | 12 +- .../net/sf/marineapi/provider/package.html | 14 +- .../racecommittee/app/AppConstants.java | 192 +++---- .../app/data/OfflineDataManager.java | 530 +++++++++--------- .../app/data/ReadonlyDataManager.java | 324 +++++------ 10 files changed, 796 insertions(+), 796 deletions(-) diff --git a/java/net.sf.marineapi/src/net/sf/marineapi/nmea/util/Side.java b/java/net.sf.marineapi/src/net/sf/marineapi/nmea/util/Side.java index 07222cf008e..81b49d38452 100755 --- a/java/net.sf.marineapi/src/net/sf/marineapi/nmea/util/Side.java +++ b/java/net.sf.marineapi/src/net/sf/marineapi/nmea/util/Side.java @@ -1,65 +1,65 @@ -/* - * Side.java - * Copyright (C) 2014 Lázár József - * - * This file is part of Java Marine API. - * - * - * Java Marine API is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Java Marine API is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Java Marine API. If not, see . - */ -package net.sf.marineapi.nmea.util; - -/** - * Defines the sides of a boat, i.e. "port" and "starboard". - * - * @author Lázár József - */ -public enum Side { - - /** Port */ - PORT('P'), - - /** Right */ - STARBOARD('S'); - - private char ch; - - private Side(char c) { - ch = c; - } - - /** - * Returns the corresponding char constant. - * - * @return Char indicator for Direction - */ - public char toChar() { - return ch; - } - - /** - * Get the enum corresponding to specified char. - * - * @param c Char indicator for Side - * @return Side - */ - public static Side valueOf(char c) { - for (Side d : values()) { - if (d.toChar() == c) { - return d; - } - } - return valueOf(String.valueOf(c)); - } -} +/* + * Side.java + * Copyright (C) 2014 Lázár József + * + * This file is part of Java Marine API. + * + * + * Java Marine API is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Java Marine API is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Java Marine API. If not, see . + */ +package net.sf.marineapi.nmea.util; + +/** + * Defines the sides of a boat, i.e. "port" and "starboard". + * + * @author Lázár József + */ +public enum Side { + + /** Port */ + PORT('P'), + + /** Right */ + STARBOARD('S'); + + private char ch; + + private Side(char c) { + ch = c; + } + + /** + * Returns the corresponding char constant. + * + * @return Char indicator for Direction + */ + public char toChar() { + return ch; + } + + /** + * Get the enum corresponding to specified char. + * + * @param c Char indicator for Side + * @return Side + */ + public static Side valueOf(char c) { + for (Side d : values()) { + if (d.toChar() == c) { + return d; + } + } + return valueOf(String.valueOf(c)); + } +} diff --git a/java/net.sf.marineapi/src/net/sf/marineapi/nmea/util/package.html b/java/net.sf.marineapi/src/net/sf/marineapi/nmea/util/package.html index 0cdc14737b9..ca202057f07 100755 --- a/java/net.sf.marineapi/src/net/sf/marineapi/nmea/util/package.html +++ b/java/net.sf.marineapi/src/net/sf/marineapi/nmea/util/package.html @@ -1,7 +1,7 @@ - - - - - Utilities and helper classes for handling the data extracted from NMEA sentences. - + + + + + Utilities and helper classes for handling the data extracted from NMEA sentences. + \ No newline at end of file diff --git a/java/net.sf.marineapi/src/net/sf/marineapi/provider/HeadingProvider.java b/java/net.sf.marineapi/src/net/sf/marineapi/provider/HeadingProvider.java index 75eec62be99..2a311cc0739 100755 --- a/java/net.sf.marineapi/src/net/sf/marineapi/provider/HeadingProvider.java +++ b/java/net.sf.marineapi/src/net/sf/marineapi/provider/HeadingProvider.java @@ -1,80 +1,80 @@ -/* - * HeadingProvider.java - * Copyright (C) 2012 Kimmo Tuukkanen - * - * This file is part of Java Marine API. - * - * - * Java Marine API is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Java Marine API is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Java Marine API. If not, see . - */ -package net.sf.marineapi.provider; - -import net.sf.marineapi.nmea.io.SentenceReader; -import net.sf.marineapi.nmea.sentence.HeadingSentence; -import net.sf.marineapi.nmea.sentence.Sentence; -import net.sf.marineapi.nmea.sentence.SentenceId; -import net.sf.marineapi.provider.event.HeadingEvent; - -/** - * Heading provider reports the vessel's current heading. Data is captured from - * HDT, HDM or HDG sentences. - * - * @author Kimmo Tuukkanen - * @see net.sf.marineapi.provider.event.HeadingEvent - * @see net.sf.marineapi.provider.event.HeadingListener - */ -public class HeadingProvider extends AbstractProvider { - - /** - * Creates a new intance of HeadingProvider. - * - * @param reader Reader for capturing heading sentences. - */ - public HeadingProvider(SentenceReader reader) { - super(reader, SentenceId.HDT, SentenceId.HDM, SentenceId.HDG); - } - - /* - * (non-Javadoc) - * @see net.sf.marineapi.provider.AbstractProvider#createEvent() - */ - @Override - protected HeadingEvent createProviderEvent() { - for (Sentence s : getSentences()) { - if (s instanceof HeadingSentence) { - return new HeadingEvent(this, (HeadingSentence) s); - } - } - return null; - } - - /* - * (non-Javadoc) - * @see net.sf.marineapi.provider.AbstractProvider#isReady() - */ - @Override - protected boolean isReady() { - return hasOne("HDT", "HDM", "HDG"); - } - - /* - * (non-Javadoc) - * @see net.sf.marineapi.provider.AbstractProvider#isValid() - */ - @Override - protected boolean isValid() { - return true; - } - -} +/* + * HeadingProvider.java + * Copyright (C) 2012 Kimmo Tuukkanen + * + * This file is part of Java Marine API. + * + * + * Java Marine API is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Java Marine API is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Java Marine API. If not, see . + */ +package net.sf.marineapi.provider; + +import net.sf.marineapi.nmea.io.SentenceReader; +import net.sf.marineapi.nmea.sentence.HeadingSentence; +import net.sf.marineapi.nmea.sentence.Sentence; +import net.sf.marineapi.nmea.sentence.SentenceId; +import net.sf.marineapi.provider.event.HeadingEvent; + +/** + * Heading provider reports the vessel's current heading. Data is captured from + * HDT, HDM or HDG sentences. + * + * @author Kimmo Tuukkanen + * @see net.sf.marineapi.provider.event.HeadingEvent + * @see net.sf.marineapi.provider.event.HeadingListener + */ +public class HeadingProvider extends AbstractProvider { + + /** + * Creates a new intance of HeadingProvider. + * + * @param reader Reader for capturing heading sentences. + */ + public HeadingProvider(SentenceReader reader) { + super(reader, SentenceId.HDT, SentenceId.HDM, SentenceId.HDG); + } + + /* + * (non-Javadoc) + * @see net.sf.marineapi.provider.AbstractProvider#createEvent() + */ + @Override + protected HeadingEvent createProviderEvent() { + for (Sentence s : getSentences()) { + if (s instanceof HeadingSentence) { + return new HeadingEvent(this, (HeadingSentence) s); + } + } + return null; + } + + /* + * (non-Javadoc) + * @see net.sf.marineapi.provider.AbstractProvider#isReady() + */ + @Override + protected boolean isReady() { + return hasOne("HDT", "HDM", "HDG"); + } + + /* + * (non-Javadoc) + * @see net.sf.marineapi.provider.AbstractProvider#isValid() + */ + @Override + protected boolean isValid() { + return true; + } + +} diff --git a/java/net.sf.marineapi/src/net/sf/marineapi/provider/event/HeadingEvent.java b/java/net.sf.marineapi/src/net/sf/marineapi/provider/event/HeadingEvent.java index 921c1ebd6a7..4f10e5df49f 100755 --- a/java/net.sf.marineapi/src/net/sf/marineapi/provider/event/HeadingEvent.java +++ b/java/net.sf.marineapi/src/net/sf/marineapi/provider/event/HeadingEvent.java @@ -1,72 +1,72 @@ -/* - * HeadingEvent.java - * Copyright (C) 2012 Kimmo Tuukkanen - * - * This file is part of Java Marine API. - * - * - * Java Marine API is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Java Marine API is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Java Marine API. If not, see . - */ -package net.sf.marineapi.provider.event; - -import net.sf.marineapi.nmea.sentence.HeadingSentence; - -/** - * HeadingProvider event, reports the current magnetic/true heading of vessel in - * degrees. - * - * @author Kimmo Tuukkanen - * @see net.sf.marineapi.provider.HeadingProvider - */ -public class HeadingEvent extends ProviderEvent { - - private static final long serialVersionUID = 5706774741081575448L; - private double heading; - private boolean isTrue; - - /** - * @param source - */ - public HeadingEvent(Object source, HeadingSentence s) { - super(source); - heading = s.getHeading(); - isTrue = s.isTrue(); - } - - /** - * Returns the current heading. - * - * @return Heading in degrees. - */ - public double getHeading() { - return heading; - } - - /** - * Tells if the heading is relative to true or magnetic north. - * - * @return true if true heading, otherwise false (magnetic). - */ - public boolean isTrue() { - return isTrue; - } - - /* - * (non-Javadoc) - * @see java.util.EventObject#toString() - */ - public String toString() { - return "[" + getHeading() + ", " + (isTrue() ? "T" : "M") + "]"; - } -} +/* + * HeadingEvent.java + * Copyright (C) 2012 Kimmo Tuukkanen + * + * This file is part of Java Marine API. + * + * + * Java Marine API is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Java Marine API is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Java Marine API. If not, see . + */ +package net.sf.marineapi.provider.event; + +import net.sf.marineapi.nmea.sentence.HeadingSentence; + +/** + * HeadingProvider event, reports the current magnetic/true heading of vessel in + * degrees. + * + * @author Kimmo Tuukkanen + * @see net.sf.marineapi.provider.HeadingProvider + */ +public class HeadingEvent extends ProviderEvent { + + private static final long serialVersionUID = 5706774741081575448L; + private double heading; + private boolean isTrue; + + /** + * @param source + */ + public HeadingEvent(Object source, HeadingSentence s) { + super(source); + heading = s.getHeading(); + isTrue = s.isTrue(); + } + + /** + * Returns the current heading. + * + * @return Heading in degrees. + */ + public double getHeading() { + return heading; + } + + /** + * Tells if the heading is relative to true or magnetic north. + * + * @return true if true heading, otherwise false (magnetic). + */ + public boolean isTrue() { + return isTrue; + } + + /* + * (non-Javadoc) + * @see java.util.EventObject#toString() + */ + public String toString() { + return "[" + getHeading() + ", " + (isTrue() ? "T" : "M") + "]"; + } +} diff --git a/java/net.sf.marineapi/src/net/sf/marineapi/provider/event/HeadingListener.java b/java/net.sf.marineapi/src/net/sf/marineapi/provider/event/HeadingListener.java index 3886f3b45b8..18c608f44fe 100755 --- a/java/net.sf.marineapi/src/net/sf/marineapi/provider/event/HeadingListener.java +++ b/java/net.sf.marineapi/src/net/sf/marineapi/provider/event/HeadingListener.java @@ -1,37 +1,37 @@ -/* - * HeadingListener.java - * Copyright (C) 2012 Kimmo Tuukkanen - * - * This file is part of Java Marine API. - * - * - * Java Marine API is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Java Marine API is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Java Marine API. If not, see . - */ -package net.sf.marineapi.provider.event; - -/** - * Listener interface for {@link net.sf.marineapi.provider.HeadingProvider}. - * - * @author Kimmo Tuukkanen - */ -public interface HeadingListener extends ProviderListener { - - /* - * (non-Javadoc) - * @see - * net.sf.marineapi.provider.event.ProviderListener#providerUpdate(net.sf - * .marineapi.provider.event.ProviderEvent) - */ - public void providerUpdate(HeadingEvent evt); -} +/* + * HeadingListener.java + * Copyright (C) 2012 Kimmo Tuukkanen + * + * This file is part of Java Marine API. + * + * + * Java Marine API is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Java Marine API is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Java Marine API. If not, see . + */ +package net.sf.marineapi.provider.event; + +/** + * Listener interface for {@link net.sf.marineapi.provider.HeadingProvider}. + * + * @author Kimmo Tuukkanen + */ +public interface HeadingListener extends ProviderListener { + + /* + * (non-Javadoc) + * @see + * net.sf.marineapi.provider.event.ProviderListener#providerUpdate(net.sf + * .marineapi.provider.event.ProviderEvent) + */ + public void providerUpdate(HeadingEvent evt); +} diff --git a/java/net.sf.marineapi/src/net/sf/marineapi/provider/event/package.html b/java/net.sf.marineapi/src/net/sf/marineapi/provider/event/package.html index ed4c2f91f40..916e9e21fc9 100755 --- a/java/net.sf.marineapi/src/net/sf/marineapi/provider/event/package.html +++ b/java/net.sf.marineapi/src/net/sf/marineapi/provider/event/package.html @@ -1,7 +1,7 @@ - - - - - Contains event classes and listener interfaces for Providers. - + + + + + Contains event classes and listener interfaces for Providers. + \ No newline at end of file diff --git a/java/net.sf.marineapi/src/net/sf/marineapi/provider/package.html b/java/net.sf.marineapi/src/net/sf/marineapi/provider/package.html index 98a73b5b45f..8bc6ecfcbfb 100755 --- a/java/net.sf.marineapi/src/net/sf/marineapi/provider/package.html +++ b/java/net.sf.marineapi/src/net/sf/marineapi/provider/package.html @@ -1,8 +1,8 @@ - - - - -

- Higher-level APIs that provide data value updates for selected measurements. - + + + + +

+ Higher-level APIs that provide data value updates for selected measurements. + \ No newline at end of file diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/AppConstants.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/AppConstants.java index b1884e5c3e7..c6e68582b94 100755 --- a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/AppConstants.java +++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/AppConstants.java @@ -1,96 +1,96 @@ -package com.sap.sailing.racecommittee.app; - -public class AppConstants { - - //TODO replace it later with BuildConfig.APPLICATION_ID (Eclipse didn't know it) - private final static String PACKAGE_NAME = "com.sap.sailing.racecommittee.app"; - - // Intent extra fields - public final static String COURSE_AREA_UUID_KEY = "courseUuid"; - public final static String INTENT_EXTRA_RACE_ID = PACKAGE_NAME + ".raceUuid"; - public final static String INTENT_EXTRA_TIMEPOINT_MILLIS = PACKAGE_NAME + ".timePoint.millis"; - public final static String INTENT_EXTRA_EVENTNAME = PACKAGE_NAME + ".eventName"; - public final static String FLAG_KEY = PACKAGE_NAME + ".raceFlag"; - public final static String EXTRA_FORCE_REFRESH = PACKAGE_NAME + ".forceRefresh"; - - public final static String AUTHOR_TYPE_OFFICER_START = "Race Officer on Start Vessel"; - public final static String AUTHOR_TYPE_OFFICER_FINISH = "Race Officer on Finish Vessel"; - public final static String AUTHOR_TYPE_SHORE_CONTROL = "Shore Control"; - public final static String AUTHOR_TYPE_VIEWER = "Viewer"; - - public final static String DARK_THEME = "dark"; - public final static String LIGHT_THEME = "light"; - - private final static String INTENT_ACTION = PACKAGE_NAME + ".action"; - public final static String INTENT_ACTION_RESET = INTENT_ACTION + ".reset"; - public final static String INTENT_ACTION_CLEAR_RACES = INTENT_ACTION + ".clearRaces"; - public final static String INTENT_ACTION_CLEANUP_RACES = INTENT_ACTION + ".cleanupRaces"; - public final static String INTENT_ACTION_ALARM_ACTION = INTENT_ACTION + ".alarmAction"; - public final static String INTENT_ACTION_RELOAD_RACES = INTENT_ACTION + ".reloadRaces"; - public final static String INTENT_ACTION_START_PROCEDURE_SPECIFIC_ACTION = INTENT_ACTION + ".startProcedureSpecificAction"; - - public final static String INTENT_ACTION_POLLING_STOP = ".stopPolling"; - public final static String INTENT_ACTION_POLLING_RACE_ADD = ".addRace"; - public final static String INTENT_ACTION_POLLING_RACE_REMOVE = ".removeRace"; - public final static String INTENT_ACTION_POLLING_POLL = ".poll"; - - // Login activity - public final static String EventIdTag = "EventId"; - - public static final int DefaultStartTimeMinuteOffset = 10; - - // Inner process events - public final static String INTENT_ACTION_TOGGLE = PACKAGE_NAME + ".action.toggle"; - - public final static String INTENT_ACTION_EXTRA = PACKAGE_NAME + ".extra"; - public final static String INTENT_ACTION_TOGGLE_PROCEDURE = "procedure"; - public final static String INTENT_ACTION_TOGGLE_PROCEDURE_MORE_MODE = "more_mode"; - public final static String INTENT_ACTION_TOGGLE_PROCEDURE_MORE_PATHFINDER = "more_pathfinder"; - public final static String INTENT_ACTION_TOGGLE_PROCEDURE_MORE_TIMING = "more_timing"; - public final static String INTENT_ACTION_TOGGLE_FACTOR = "factor"; - public final static String INTENT_ACTION_TOGGLE_COURSE = "course"; - public final static String INTENT_ACTION_TOGGLE_WIND = "wind"; - public final static String INTENT_ACTION_TOGGLE_TIME = "time"; - public final static String INTENT_ACTION_TOGGLE_POSTPONE = "postpone"; - public final static String INTENT_ACTION_TOGGLE_ABANDON = "abandon"; - public final static String INTENT_ACTION_TOGGLE_RECALL = "recall"; - public final static String INTENT_ACTION_TOGGLE_BLUE_FIRST = "more"; - public final static String INTENT_ACTION_TOGGLE_BLUE_LAST = "blue_last"; - - public final static String INTENT_ACTION_TOGGLE_REPLAY = "replay"; - public final static String INTENT_ACTION_TOGGLE_PHOTOS = "photos"; - public final static String INTENT_ACTION_TOGGLE_LIST = "list"; - - public final static String INTENT_ACTION_TOGGLE_EVENT = "event"; - public final static String INTENT_ACTION_TOGGLE_AREA = "area"; - public final static String INTENT_ACTION_TOGGLE_POSITION = "position"; - - private final static String INTENT_ACTION_TIME = PACKAGE_NAME + "action.time"; - public final static String INTENT_ACTION_TIME_HIDE = INTENT_ACTION_TIME + ".hide"; - public final static String INTENT_ACTION_TIME_SHOW = INTENT_ACTION_TIME + ".show"; - - public final static String INTENT_ACTION_CHECK_LOGIN = "show_empty_screen"; - public final static String INTENT_ACTION_SHOW_ONBOARDING = "show_onboarding"; - public final static String INTENT_ACTION_SHOW_LOGIN = "show_login"; - public final static String INTENT_ACTION_VALID_DATA = "valid_data"; - public final static String INTENT_ACTION_SHOW_WELCOME = "show_welcome"; - - // clears all toggle buttons - public final static String INTENT_ACTION_CLEAR_TOGGLE = PACKAGE_NAME + ".action.toggle.clear"; - - public final static String INTENT_ACTION_UPDATE_SCREEN = PACKAGE_NAME + ".action.update.screen"; - public final static String INTENT_ACTION_SHOW_MAIN_CONTENT = PACKAGE_NAME + ".action.show.main"; - public final static String INTENT_ACTION_SHOW_SUMMARY_CONTENT = PACKAGE_NAME + ".action.show.summary"; - - /** - * As extra this intent expects the String obtained for a FilterableRace / ManagedRace using - * {@code new RaceGroupSeries(race.getRaceGroup(), race.getSeries()).getDisplayName()}. - */ - public final static String INTENT_ACTION_SHOW_PROTEST = PACKAGE_NAME + ".action.show.protest"; - public final static String INTENT_ACTION_REMOVE_PROTEST = PACKAGE_NAME + ".action.remove.protest"; - - public final static String INTENT_ACTION_IS_TRACKING = PACKAGE_NAME + "action.is.tracking"; - public final static String INTENT_ACTION_IS_TRACKING_EXTRA = PACKAGE_NAME + "action.is.tracking.extra"; - - public final static String GWT_MAP_AND_WIND_CHART_HTML = "gwt/EmbeddedMapAndWindChart.html"; -} +package com.sap.sailing.racecommittee.app; + +public class AppConstants { + + //TODO replace it later with BuildConfig.APPLICATION_ID (Eclipse didn't know it) + private final static String PACKAGE_NAME = "com.sap.sailing.racecommittee.app"; + + // Intent extra fields + public final static String COURSE_AREA_UUID_KEY = "courseUuid"; + public final static String INTENT_EXTRA_RACE_ID = PACKAGE_NAME + ".raceUuid"; + public final static String INTENT_EXTRA_TIMEPOINT_MILLIS = PACKAGE_NAME + ".timePoint.millis"; + public final static String INTENT_EXTRA_EVENTNAME = PACKAGE_NAME + ".eventName"; + public final static String FLAG_KEY = PACKAGE_NAME + ".raceFlag"; + public final static String EXTRA_FORCE_REFRESH = PACKAGE_NAME + ".forceRefresh"; + + public final static String AUTHOR_TYPE_OFFICER_START = "Race Officer on Start Vessel"; + public final static String AUTHOR_TYPE_OFFICER_FINISH = "Race Officer on Finish Vessel"; + public final static String AUTHOR_TYPE_SHORE_CONTROL = "Shore Control"; + public final static String AUTHOR_TYPE_VIEWER = "Viewer"; + + public final static String DARK_THEME = "dark"; + public final static String LIGHT_THEME = "light"; + + private final static String INTENT_ACTION = PACKAGE_NAME + ".action"; + public final static String INTENT_ACTION_RESET = INTENT_ACTION + ".reset"; + public final static String INTENT_ACTION_CLEAR_RACES = INTENT_ACTION + ".clearRaces"; + public final static String INTENT_ACTION_CLEANUP_RACES = INTENT_ACTION + ".cleanupRaces"; + public final static String INTENT_ACTION_ALARM_ACTION = INTENT_ACTION + ".alarmAction"; + public final static String INTENT_ACTION_RELOAD_RACES = INTENT_ACTION + ".reloadRaces"; + public final static String INTENT_ACTION_START_PROCEDURE_SPECIFIC_ACTION = INTENT_ACTION + ".startProcedureSpecificAction"; + + public final static String INTENT_ACTION_POLLING_STOP = ".stopPolling"; + public final static String INTENT_ACTION_POLLING_RACE_ADD = ".addRace"; + public final static String INTENT_ACTION_POLLING_RACE_REMOVE = ".removeRace"; + public final static String INTENT_ACTION_POLLING_POLL = ".poll"; + + // Login activity + public final static String EventIdTag = "EventId"; + + public static final int DefaultStartTimeMinuteOffset = 10; + + // Inner process events + public final static String INTENT_ACTION_TOGGLE = PACKAGE_NAME + ".action.toggle"; + + public final static String INTENT_ACTION_EXTRA = PACKAGE_NAME + ".extra"; + public final static String INTENT_ACTION_TOGGLE_PROCEDURE = "procedure"; + public final static String INTENT_ACTION_TOGGLE_PROCEDURE_MORE_MODE = "more_mode"; + public final static String INTENT_ACTION_TOGGLE_PROCEDURE_MORE_PATHFINDER = "more_pathfinder"; + public final static String INTENT_ACTION_TOGGLE_PROCEDURE_MORE_TIMING = "more_timing"; + public final static String INTENT_ACTION_TOGGLE_FACTOR = "factor"; + public final static String INTENT_ACTION_TOGGLE_COURSE = "course"; + public final static String INTENT_ACTION_TOGGLE_WIND = "wind"; + public final static String INTENT_ACTION_TOGGLE_TIME = "time"; + public final static String INTENT_ACTION_TOGGLE_POSTPONE = "postpone"; + public final static String INTENT_ACTION_TOGGLE_ABANDON = "abandon"; + public final static String INTENT_ACTION_TOGGLE_RECALL = "recall"; + public final static String INTENT_ACTION_TOGGLE_BLUE_FIRST = "more"; + public final static String INTENT_ACTION_TOGGLE_BLUE_LAST = "blue_last"; + + public final static String INTENT_ACTION_TOGGLE_REPLAY = "replay"; + public final static String INTENT_ACTION_TOGGLE_PHOTOS = "photos"; + public final static String INTENT_ACTION_TOGGLE_LIST = "list"; + + public final static String INTENT_ACTION_TOGGLE_EVENT = "event"; + public final static String INTENT_ACTION_TOGGLE_AREA = "area"; + public final static String INTENT_ACTION_TOGGLE_POSITION = "position"; + + private final static String INTENT_ACTION_TIME = PACKAGE_NAME + "action.time"; + public final static String INTENT_ACTION_TIME_HIDE = INTENT_ACTION_TIME + ".hide"; + public final static String INTENT_ACTION_TIME_SHOW = INTENT_ACTION_TIME + ".show"; + + public final static String INTENT_ACTION_CHECK_LOGIN = "show_empty_screen"; + public final static String INTENT_ACTION_SHOW_ONBOARDING = "show_onboarding"; + public final static String INTENT_ACTION_SHOW_LOGIN = "show_login"; + public final static String INTENT_ACTION_VALID_DATA = "valid_data"; + public final static String INTENT_ACTION_SHOW_WELCOME = "show_welcome"; + + // clears all toggle buttons + public final static String INTENT_ACTION_CLEAR_TOGGLE = PACKAGE_NAME + ".action.toggle.clear"; + + public final static String INTENT_ACTION_UPDATE_SCREEN = PACKAGE_NAME + ".action.update.screen"; + public final static String INTENT_ACTION_SHOW_MAIN_CONTENT = PACKAGE_NAME + ".action.show.main"; + public final static String INTENT_ACTION_SHOW_SUMMARY_CONTENT = PACKAGE_NAME + ".action.show.summary"; + + /** + * As extra this intent expects the String obtained for a FilterableRace / ManagedRace using + * {@code new RaceGroupSeries(race.getRaceGroup(), race.getSeries()).getDisplayName()}. + */ + public final static String INTENT_ACTION_SHOW_PROTEST = PACKAGE_NAME + ".action.show.protest"; + public final static String INTENT_ACTION_REMOVE_PROTEST = PACKAGE_NAME + ".action.remove.protest"; + + public final static String INTENT_ACTION_IS_TRACKING = PACKAGE_NAME + "action.is.tracking"; + public final static String INTENT_ACTION_IS_TRACKING_EXTRA = PACKAGE_NAME + "action.is.tracking.extra"; + + public final static String GWT_MAP_AND_WIND_CHART_HTML = "gwt/EmbeddedMapAndWindChart.html"; +} diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/data/OfflineDataManager.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/data/OfflineDataManager.java index ec72a1187e1..87a1f52a5cc 100644 --- a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/data/OfflineDataManager.java +++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/data/OfflineDataManager.java @@ -1,265 +1,265 @@ -package com.sap.sailing.racecommittee.app.data; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.Callable; - -import android.app.LoaderManager.LoaderCallbacks; -import android.content.Context; - -import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor; -import com.sap.sailing.domain.abstractlog.race.RaceLog; -import com.sap.sailing.domain.abstractlog.race.impl.RaceLogImpl; -import com.sap.sailing.domain.abstractlog.race.impl.RaceLogRaceStatusEventImpl; -import com.sap.sailing.domain.abstractlog.race.impl.RaceLogStartTimeEventImpl; -import com.sap.sailing.domain.abstractlog.race.state.impl.RaceStateImpl; -import com.sap.sailing.domain.base.Competitor; -import com.sap.sailing.domain.base.CourseArea; -import com.sap.sailing.domain.base.CourseBase; -import com.sap.sailing.domain.base.EventBase; -import com.sap.sailing.domain.base.LeaderboardGroupBase; -import com.sap.sailing.domain.base.Mark; -import com.sap.sailing.domain.base.SharedDomainFactory; -import com.sap.sailing.domain.base.configuration.ConfigurationLoader; -import com.sap.sailing.domain.base.configuration.DeviceConfiguration; -import com.sap.sailing.domain.base.configuration.DeviceConfigurationIdentifier; -import com.sap.sailing.domain.base.configuration.RegattaConfiguration; -import com.sap.sailing.domain.base.configuration.impl.EmptyRegattaConfiguration; -import com.sap.sailing.domain.base.impl.BoatClassImpl; -import com.sap.sailing.domain.base.impl.CompetitorImpl; -import com.sap.sailing.domain.base.impl.CourseAreaImpl; -import com.sap.sailing.domain.base.impl.FleetImpl; -import com.sap.sailing.domain.base.impl.MarkImpl; -import com.sap.sailing.domain.base.impl.RaceColumnFactorImpl; -import com.sap.sailing.domain.base.impl.StrippedEventImpl; -import com.sap.sailing.domain.base.racegroup.RaceGroup; -import com.sap.sailing.domain.base.racegroup.SeriesWithRows; -import com.sap.sailing.domain.base.racegroup.impl.RaceGroupImpl; -import com.sap.sailing.domain.base.racegroup.impl.SeriesWithRowsImpl; -import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus; -import com.sap.sailing.racecommittee.app.AppPreferences; -import com.sap.sailing.racecommittee.app.data.clients.LoadClient; -import com.sap.sailing.racecommittee.app.data.loaders.DataLoaderResult; -import com.sap.sailing.racecommittee.app.data.loaders.ImmediateDataLoaderCallbacks; -import com.sap.sailing.racecommittee.app.domain.CoursePosition; -import com.sap.sailing.racecommittee.app.domain.ManagedRace; -import com.sap.sailing.racecommittee.app.domain.configuration.impl.PreferencesRegattaConfigurationLoader; -import com.sap.sailing.racecommittee.app.domain.impl.ManagedRaceIdentifierImpl; -import com.sap.sailing.racecommittee.app.domain.impl.ManagedRaceImpl; -import com.sap.sailing.racecommittee.app.ui.fragments.lists.PositionListFragment; -import com.sap.sse.common.Color; -import com.sap.sse.common.TimePoint; -import com.sap.sse.common.impl.MillisecondsTimePoint; - -public class OfflineDataManager extends DataManager { - - private static boolean isInitialized = false; - private final Context context; - - protected OfflineDataManager(Context context, DataStore dataStore, SharedDomainFactory domainFactory) { - super(context, dataStore, domainFactory); - this.context = context; - if (!isInitialized) { - isInitialized = true; - fillDataStore(dataStore); - } - } - - private void fillDataStore(DataStore dataStore) { - Calendar cal = Calendar.getInstance(); - cal.set(2012, 12, 1); - final TimePoint startDate = new MillisecondsTimePoint(cal.getTimeInMillis()); - cal.set(2012, 12, 5); - final TimePoint endDate = new MillisecondsTimePoint(cal.getTimeInMillis()); - - dataStore.addEvent(new StrippedEventImpl("Extreme Sailing Series 2012 (Cardiff)", startDate, endDate, "Cardiff", true, UUID.randomUUID(), Collections. emptySet())); - dataStore.addEvent(new StrippedEventImpl("Extreme Sailing Series 2012 (Nice)", startDate, endDate, "Nice", true, UUID.randomUUID(), Collections. emptySet())); - dataStore.addEvent(new StrippedEventImpl("Extreme Sailing Series 2012 (Rio)", startDate, endDate, "Rio", true, UUID.randomUUID(), Collections. emptySet())); - EventBase newEvent = new StrippedEventImpl("Extreme Sailing Series 2013 (Muscat)", startDate, endDate, "Muscat", true, UUID.randomUUID(), Collections. emptySet()); - newEvent.getVenue().addCourseArea(new CourseAreaImpl("Offshore", UUID.randomUUID())); - newEvent.getVenue().addCourseArea(new CourseAreaImpl("Stadium", UUID.randomUUID())); - dataStore.addEvent(newEvent); - - SeriesWithRows qualifying = new SeriesWithRowsImpl("Qualifying", false, /* isFleetsCanRunInParallel */ true, null); - SeriesWithRows medal = new SeriesWithRowsImpl("Medal", true, /* isFleetsCanRunInParallel */ true, null); - RaceGroup raceGroup = new RaceGroupImpl("ESS", /* displayName */ null, new BoatClassImpl("X40", false), null, Arrays.asList(qualifying, - medal), new EmptyRegattaConfiguration()); - - List competitors = new ArrayList(); - competitors.add(new CompetitorImpl(UUID.randomUUID(), "SAP Extreme Sailing Team", Color.BLUE, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null, null)); - competitors.add(new CompetitorImpl(UUID.randomUUID(), "The Wave Muscat", Color.LIGHT_GRAY, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null, null)); - competitors.add(new CompetitorImpl(UUID.randomUUID(), "Red Bull Extreme Sailing Team", Color.RED, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null, null)); - competitors.add(new CompetitorImpl(UUID.randomUUID(), "Team Korea", Color.GREEN, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null, null)); - competitors.add(new CompetitorImpl(UUID.randomUUID(), "Realteam", Color.BLACK, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null, null)); - - RaceLog log = new RaceLogImpl(UUID.randomUUID()); - final AbstractLogEventAuthor author = AppPreferences.on(context).getAuthor(); - ConfigurationLoader configuration = PreferencesRegattaConfigurationLoader - .loadFromPreferences(preferences); - - log.add(new RaceLogStartTimeEventImpl(new MillisecondsTimePoint(new Date().getTime() - 2000), author, 1, - new MillisecondsTimePoint(new Date().getTime() - 1000))); - - log.add(new RaceLogRaceStatusEventImpl(new MillisecondsTimePoint(new Date().getTime()), - AppPreferences.on(context).getAuthor(), 1, RaceLogRaceStatus.FINISHING)); - - ManagedRace q1 = new ManagedRaceImpl(new ManagedRaceIdentifierImpl("A.B", new FleetImpl("A"), qualifying, raceGroup), - RaceStateImpl.create(new AndroidRaceLogResolver(), log, AppPreferences.on(context).getAuthor(), configuration), - /* zeroBasedIndexInFleet */ 0); - - log = new RaceLogImpl(UUID.randomUUID()); - /* - * log.add(factory.createStartTimeEvent( new MillisecondsTimePoint(new Date()), 1, RaceLogRaceStatus.SCHEDULED, - * new MillisecondsTimePoint(new Date().getTime() + 100000))); - */ - - ManagedRace q2 = new ManagedRaceImpl(new ManagedRaceIdentifierImpl("B", new FleetImpl("A.A"), qualifying, raceGroup), - RaceStateImpl.create(new AndroidRaceLogResolver(), log, AppPreferences.on(context).getAuthor(), configuration), - /* zeroBasedIndexInFleet */ 1); - - log = new RaceLogImpl(UUID.randomUUID()); - /* - * log.add(factory.createRaceStatusEvent( new MillisecondsTimePoint(new Date()), 5, - * RaceLogRaceStatus.FINISHED)); - */ - ManagedRace q3 = new ManagedRaceImpl(new ManagedRaceIdentifierImpl("Q3", new FleetImpl("Default"), qualifying, raceGroup), - RaceStateImpl.create(new AndroidRaceLogResolver(), log, AppPreferences.on(context).getAuthor(), configuration), - /* zeroBasedIndexInFleet */ 2); - /* - * ManagedRace m1 = new ManagedRaceImpl( new ManagedRaceIdentifierImpl( "M1", new FleetImpl("Default"), medal, - * raceGroup), null); - */ - dataStore.addRace(q1); - dataStore.addRace(q2); - dataStore.addRace(q3); - // dataStore.addRace(m1); - - Mark m1 = new MarkImpl("Red"); - Mark m2 = new MarkImpl("Green"); - Mark m3 = new MarkImpl("White"); - - dataStore.addMark(m1); - dataStore.addMark(m2); - dataStore.addMark(m3); - } - - @Override - public LoaderCallbacks>> createEventsLoader( - LoadClient> callback) { - return new ImmediateDataLoaderCallbacks>(context, callback, - new Callable>() { - @Override - public Collection call() throws Exception { - return dataStore.getEvents(); - } - }); - } - - @Override - public LoaderCallbacks>> createCourseAreasLoader( - final Serializable parentEventId, LoadClient> callback) { - return new ImmediateDataLoaderCallbacks>(context, callback, - new Callable>() { - @Override - public Collection call() throws Exception { - return dataStore.getCourseAreas(dataStore.getEvent(parentEventId)); - } - }); - } - - @Override - public LoaderCallbacks>> createCourseAreasLoader( - final EventBase parentEvent, LoadClient> callback) { - // TODO Auto-generated method stub - return new ImmediateDataLoaderCallbacks>(context, callback, - new Callable>() { - @Override - public Collection call() throws Exception { - return dataStore.getCourseAreas(parentEvent); - } - }); - } - - @Override - public LoaderCallbacks>> createRacesLoader(Serializable courseAreaId, - LoadClient> callback) { - return new ImmediateDataLoaderCallbacks>(context, callback, - new Callable>() { - @Override - public Collection call() throws Exception { - return dataStore.getRaces(); - } - }); - } - - @Override - public LoaderCallbacks>> createMarksLoader(ManagedRace managedRace, - LoadClient> callback) { - return new ImmediateDataLoaderCallbacks>(context, callback, new Callable>() { - @Override - public Collection call() throws Exception { - return dataStore.getMarks(); - } - }); - } - - @Override - public LoaderCallbacks> createCourseLoader(final ManagedRace managedRace, - LoadClient callback) { - return new ImmediateDataLoaderCallbacks(context, callback, new Callable() { - @Override - public CourseBase call() throws Exception { - return managedRace.getCourseOnServer(); - } - }); - } - - @Override - public LoaderCallbacks>> createCompetitorsLoader( - final ManagedRace managedRace, LoadClient> callback) { - return new ImmediateDataLoaderCallbacks>(context, callback, - new Callable>() { - @Override - public Collection call() throws Exception { - return managedRace.getCompetitors(); - } - }); - } - - @Override - public LoaderCallbacks> createConfigurationLoader( - DeviceConfigurationIdentifier identifier, LoadClient callback) { - return new ImmediateDataLoaderCallbacks(context, callback, - new Callable() { - @Override - public DeviceConfiguration call() throws Exception { - throw new IllegalStateException("No remote configuration in offline mode."); - } - }); - } - - @Override - public String getMapUrl(String baseUrl, ManagedRace race, String eventId, boolean showWindCharts, boolean showStreamlets, boolean showSimulation, - boolean showMapControls) { - throw new IllegalStateException("No wind map in offline mode."); - } - - @Override - public LoaderCallbacks>> createPositionLoader( - PositionListFragment positionListFragment) { - // TODO Auto-generated method stub - return null; - } - - @Override - public LoaderCallbacks> createRaceColumnFactorLoader(LoadClient callback) { - return null; - } -} +package com.sap.sailing.racecommittee.app.data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.Callable; + +import android.app.LoaderManager.LoaderCallbacks; +import android.content.Context; + +import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor; +import com.sap.sailing.domain.abstractlog.race.RaceLog; +import com.sap.sailing.domain.abstractlog.race.impl.RaceLogImpl; +import com.sap.sailing.domain.abstractlog.race.impl.RaceLogRaceStatusEventImpl; +import com.sap.sailing.domain.abstractlog.race.impl.RaceLogStartTimeEventImpl; +import com.sap.sailing.domain.abstractlog.race.state.impl.RaceStateImpl; +import com.sap.sailing.domain.base.Competitor; +import com.sap.sailing.domain.base.CourseArea; +import com.sap.sailing.domain.base.CourseBase; +import com.sap.sailing.domain.base.EventBase; +import com.sap.sailing.domain.base.LeaderboardGroupBase; +import com.sap.sailing.domain.base.Mark; +import com.sap.sailing.domain.base.SharedDomainFactory; +import com.sap.sailing.domain.base.configuration.ConfigurationLoader; +import com.sap.sailing.domain.base.configuration.DeviceConfiguration; +import com.sap.sailing.domain.base.configuration.DeviceConfigurationIdentifier; +import com.sap.sailing.domain.base.configuration.RegattaConfiguration; +import com.sap.sailing.domain.base.configuration.impl.EmptyRegattaConfiguration; +import com.sap.sailing.domain.base.impl.BoatClassImpl; +import com.sap.sailing.domain.base.impl.CompetitorImpl; +import com.sap.sailing.domain.base.impl.CourseAreaImpl; +import com.sap.sailing.domain.base.impl.FleetImpl; +import com.sap.sailing.domain.base.impl.MarkImpl; +import com.sap.sailing.domain.base.impl.RaceColumnFactorImpl; +import com.sap.sailing.domain.base.impl.StrippedEventImpl; +import com.sap.sailing.domain.base.racegroup.RaceGroup; +import com.sap.sailing.domain.base.racegroup.SeriesWithRows; +import com.sap.sailing.domain.base.racegroup.impl.RaceGroupImpl; +import com.sap.sailing.domain.base.racegroup.impl.SeriesWithRowsImpl; +import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus; +import com.sap.sailing.racecommittee.app.AppPreferences; +import com.sap.sailing.racecommittee.app.data.clients.LoadClient; +import com.sap.sailing.racecommittee.app.data.loaders.DataLoaderResult; +import com.sap.sailing.racecommittee.app.data.loaders.ImmediateDataLoaderCallbacks; +import com.sap.sailing.racecommittee.app.domain.CoursePosition; +import com.sap.sailing.racecommittee.app.domain.ManagedRace; +import com.sap.sailing.racecommittee.app.domain.configuration.impl.PreferencesRegattaConfigurationLoader; +import com.sap.sailing.racecommittee.app.domain.impl.ManagedRaceIdentifierImpl; +import com.sap.sailing.racecommittee.app.domain.impl.ManagedRaceImpl; +import com.sap.sailing.racecommittee.app.ui.fragments.lists.PositionListFragment; +import com.sap.sse.common.Color; +import com.sap.sse.common.TimePoint; +import com.sap.sse.common.impl.MillisecondsTimePoint; + +public class OfflineDataManager extends DataManager { + + private static boolean isInitialized = false; + private final Context context; + + protected OfflineDataManager(Context context, DataStore dataStore, SharedDomainFactory domainFactory) { + super(context, dataStore, domainFactory); + this.context = context; + if (!isInitialized) { + isInitialized = true; + fillDataStore(dataStore); + } + } + + private void fillDataStore(DataStore dataStore) { + Calendar cal = Calendar.getInstance(); + cal.set(2012, 12, 1); + final TimePoint startDate = new MillisecondsTimePoint(cal.getTimeInMillis()); + cal.set(2012, 12, 5); + final TimePoint endDate = new MillisecondsTimePoint(cal.getTimeInMillis()); + + dataStore.addEvent(new StrippedEventImpl("Extreme Sailing Series 2012 (Cardiff)", startDate, endDate, "Cardiff", true, UUID.randomUUID(), Collections. emptySet())); + dataStore.addEvent(new StrippedEventImpl("Extreme Sailing Series 2012 (Nice)", startDate, endDate, "Nice", true, UUID.randomUUID(), Collections. emptySet())); + dataStore.addEvent(new StrippedEventImpl("Extreme Sailing Series 2012 (Rio)", startDate, endDate, "Rio", true, UUID.randomUUID(), Collections. emptySet())); + EventBase newEvent = new StrippedEventImpl("Extreme Sailing Series 2013 (Muscat)", startDate, endDate, "Muscat", true, UUID.randomUUID(), Collections. emptySet()); + newEvent.getVenue().addCourseArea(new CourseAreaImpl("Offshore", UUID.randomUUID())); + newEvent.getVenue().addCourseArea(new CourseAreaImpl("Stadium", UUID.randomUUID())); + dataStore.addEvent(newEvent); + + SeriesWithRows qualifying = new SeriesWithRowsImpl("Qualifying", false, /* isFleetsCanRunInParallel */ true, null); + SeriesWithRows medal = new SeriesWithRowsImpl("Medal", true, /* isFleetsCanRunInParallel */ true, null); + RaceGroup raceGroup = new RaceGroupImpl("ESS", /* displayName */ null, new BoatClassImpl("X40", false), null, Arrays.asList(qualifying, + medal), new EmptyRegattaConfiguration()); + + List competitors = new ArrayList(); + competitors.add(new CompetitorImpl(UUID.randomUUID(), "SAP Extreme Sailing Team", Color.BLUE, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null, null)); + competitors.add(new CompetitorImpl(UUID.randomUUID(), "The Wave Muscat", Color.LIGHT_GRAY, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null, null)); + competitors.add(new CompetitorImpl(UUID.randomUUID(), "Red Bull Extreme Sailing Team", Color.RED, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null, null)); + competitors.add(new CompetitorImpl(UUID.randomUUID(), "Team Korea", Color.GREEN, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null, null)); + competitors.add(new CompetitorImpl(UUID.randomUUID(), "Realteam", Color.BLACK, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null, null)); + + RaceLog log = new RaceLogImpl(UUID.randomUUID()); + final AbstractLogEventAuthor author = AppPreferences.on(context).getAuthor(); + ConfigurationLoader configuration = PreferencesRegattaConfigurationLoader + .loadFromPreferences(preferences); + + log.add(new RaceLogStartTimeEventImpl(new MillisecondsTimePoint(new Date().getTime() - 2000), author, 1, + new MillisecondsTimePoint(new Date().getTime() - 1000))); + + log.add(new RaceLogRaceStatusEventImpl(new MillisecondsTimePoint(new Date().getTime()), + AppPreferences.on(context).getAuthor(), 1, RaceLogRaceStatus.FINISHING)); + + ManagedRace q1 = new ManagedRaceImpl(new ManagedRaceIdentifierImpl("A.B", new FleetImpl("A"), qualifying, raceGroup), + RaceStateImpl.create(new AndroidRaceLogResolver(), log, AppPreferences.on(context).getAuthor(), configuration), + /* zeroBasedIndexInFleet */ 0); + + log = new RaceLogImpl(UUID.randomUUID()); + /* + * log.add(factory.createStartTimeEvent( new MillisecondsTimePoint(new Date()), 1, RaceLogRaceStatus.SCHEDULED, + * new MillisecondsTimePoint(new Date().getTime() + 100000))); + */ + + ManagedRace q2 = new ManagedRaceImpl(new ManagedRaceIdentifierImpl("B", new FleetImpl("A.A"), qualifying, raceGroup), + RaceStateImpl.create(new AndroidRaceLogResolver(), log, AppPreferences.on(context).getAuthor(), configuration), + /* zeroBasedIndexInFleet */ 1); + + log = new RaceLogImpl(UUID.randomUUID()); + /* + * log.add(factory.createRaceStatusEvent( new MillisecondsTimePoint(new Date()), 5, + * RaceLogRaceStatus.FINISHED)); + */ + ManagedRace q3 = new ManagedRaceImpl(new ManagedRaceIdentifierImpl("Q3", new FleetImpl("Default"), qualifying, raceGroup), + RaceStateImpl.create(new AndroidRaceLogResolver(), log, AppPreferences.on(context).getAuthor(), configuration), + /* zeroBasedIndexInFleet */ 2); + /* + * ManagedRace m1 = new ManagedRaceImpl( new ManagedRaceIdentifierImpl( "M1", new FleetImpl("Default"), medal, + * raceGroup), null); + */ + dataStore.addRace(q1); + dataStore.addRace(q2); + dataStore.addRace(q3); + // dataStore.addRace(m1); + + Mark m1 = new MarkImpl("Red"); + Mark m2 = new MarkImpl("Green"); + Mark m3 = new MarkImpl("White"); + + dataStore.addMark(m1); + dataStore.addMark(m2); + dataStore.addMark(m3); + } + + @Override + public LoaderCallbacks>> createEventsLoader( + LoadClient> callback) { + return new ImmediateDataLoaderCallbacks>(context, callback, + new Callable>() { + @Override + public Collection call() throws Exception { + return dataStore.getEvents(); + } + }); + } + + @Override + public LoaderCallbacks>> createCourseAreasLoader( + final Serializable parentEventId, LoadClient> callback) { + return new ImmediateDataLoaderCallbacks>(context, callback, + new Callable>() { + @Override + public Collection call() throws Exception { + return dataStore.getCourseAreas(dataStore.getEvent(parentEventId)); + } + }); + } + + @Override + public LoaderCallbacks>> createCourseAreasLoader( + final EventBase parentEvent, LoadClient> callback) { + // TODO Auto-generated method stub + return new ImmediateDataLoaderCallbacks>(context, callback, + new Callable>() { + @Override + public Collection call() throws Exception { + return dataStore.getCourseAreas(parentEvent); + } + }); + } + + @Override + public LoaderCallbacks>> createRacesLoader(Serializable courseAreaId, + LoadClient> callback) { + return new ImmediateDataLoaderCallbacks>(context, callback, + new Callable>() { + @Override + public Collection call() throws Exception { + return dataStore.getRaces(); + } + }); + } + + @Override + public LoaderCallbacks>> createMarksLoader(ManagedRace managedRace, + LoadClient> callback) { + return new ImmediateDataLoaderCallbacks>(context, callback, new Callable>() { + @Override + public Collection call() throws Exception { + return dataStore.getMarks(); + } + }); + } + + @Override + public LoaderCallbacks> createCourseLoader(final ManagedRace managedRace, + LoadClient callback) { + return new ImmediateDataLoaderCallbacks(context, callback, new Callable() { + @Override + public CourseBase call() throws Exception { + return managedRace.getCourseOnServer(); + } + }); + } + + @Override + public LoaderCallbacks>> createCompetitorsLoader( + final ManagedRace managedRace, LoadClient> callback) { + return new ImmediateDataLoaderCallbacks>(context, callback, + new Callable>() { + @Override + public Collection call() throws Exception { + return managedRace.getCompetitors(); + } + }); + } + + @Override + public LoaderCallbacks> createConfigurationLoader( + DeviceConfigurationIdentifier identifier, LoadClient callback) { + return new ImmediateDataLoaderCallbacks(context, callback, + new Callable() { + @Override + public DeviceConfiguration call() throws Exception { + throw new IllegalStateException("No remote configuration in offline mode."); + } + }); + } + + @Override + public String getMapUrl(String baseUrl, ManagedRace race, String eventId, boolean showWindCharts, boolean showStreamlets, boolean showSimulation, + boolean showMapControls) { + throw new IllegalStateException("No wind map in offline mode."); + } + + @Override + public LoaderCallbacks>> createPositionLoader( + PositionListFragment positionListFragment) { + // TODO Auto-generated method stub + return null; + } + + @Override + public LoaderCallbacks> createRaceColumnFactorLoader(LoadClient callback) { + return null; + } +} diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/data/ReadonlyDataManager.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/data/ReadonlyDataManager.java index 55c638dc39d..3b97bf7d291 100644 --- a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/data/ReadonlyDataManager.java +++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/data/ReadonlyDataManager.java @@ -1,162 +1,162 @@ -package com.sap.sailing.racecommittee.app.data; - -import java.io.Serializable; -import java.util.Collection; - -import com.sap.sailing.domain.base.Competitor; -import com.sap.sailing.domain.base.CourseArea; -import com.sap.sailing.domain.base.CourseBase; -import com.sap.sailing.domain.base.EventBase; -import com.sap.sailing.domain.base.Mark; -import com.sap.sailing.domain.base.configuration.DeviceConfiguration; -import com.sap.sailing.domain.base.configuration.DeviceConfigurationIdentifier; -import com.sap.sailing.domain.base.impl.RaceColumnFactorImpl; -import com.sap.sailing.racecommittee.app.data.clients.LoadClient; -import com.sap.sailing.racecommittee.app.data.loaders.DataLoaderResult; -import com.sap.sailing.racecommittee.app.domain.CoursePosition; -import com.sap.sailing.racecommittee.app.domain.ManagedRace; -import com.sap.sailing.racecommittee.app.ui.fragments.lists.PositionListFragment; - -import android.app.LoaderManager; -import android.app.LoaderManager.LoaderCallbacks; - -/** - *

- * Interface for everything read related when working with data. - *

- * - *

- * The result values of this interface's methods are meant to be used in conjunction with the Android's - * {@link LoaderManager} facility. Everything that is loaded by this interface is stored and cached in the underlying - * {@link DataStore}. - *

- * - *

- * If there are cached results your {@link LoadClient}'s callback methods might be called twice (first cached results; - * afterwards remote results). See {@link LoadClient} for restrictions that apply to your data handling code. - *

- */ -public interface ReadonlyDataManager { - - /** - * Gets the underlying data store. - * - * @return the {@link DataStore}. - */ - DataStore getDataStore(); - - /** - * Creates a new {@link LoaderCallbacks} object for loading {@link EventBase}s. - * - * @param callback - * {@link LoadClient} implementing your data handling code. - * @return {@link LoaderCallbacks} to be used in - * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or - * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. - */ - LoaderCallbacks>> createEventsLoader(LoadClient> callback); - - /** - * Creates a new {@link LoaderCallbacks} object for loading {@link CourseArea}s. - * - * @param callback - * {@link LoadClient} implementing your data handling code. - * @return {@link LoaderCallbacks} to be used in - * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or - * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. - */ - LoaderCallbacks>> createCourseAreasLoader(Serializable parentEventId, - LoadClient> callback); - - LoaderCallbacks>> createCourseAreasLoader(EventBase parentEvent, - LoadClient> callback); - - /** - * Creates a new {@link LoaderCallbacks} object for loading racing referee positions. - * - * @return {@link LoaderCallbacks} to be used in - * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or - * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. - */ - LoaderCallbacks>> createPositionLoader(PositionListFragment positionListFragment); - - /** - * Creates a new {@link LoaderCallbacks} object for loading {@link ManagedRace}s of a specific {@link CourseArea}. - * - * @param courseAreaId - * the {@link CourseArea}'s Identifier. - * @param callback - * {@link LoadClient} implementing your data handling code. - * @return {@link LoaderCallbacks} to be used in - * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or - * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. - */ - LoaderCallbacks>> createRacesLoader(Serializable courseAreaId, - LoadClient> callback); - - /** - * Creates a new {@link LoaderCallbacks} object for loading a race's {@link Mark}s. - * - * @param managedRace - * the {@link ManagedRace}. - * @param callback - * {@link LoadClient} implementing your data handling code. - * @return {@link LoaderCallbacks} to be used in - * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or - * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. - */ - LoaderCallbacks>> createMarksLoader(ManagedRace managedRace, LoadClient> callback); - - /** - * Creates a new {@link LoaderCallbacks} object for loading a race's {@link CourseBase}. - * - * @param managedRace - * the {@link ManagedRace}. - * @param callback - * {@link LoadClient} implementing your data handling code. - * @return {@link LoaderCallbacks} to be used in - * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or - * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. - */ - LoaderCallbacks> createCourseLoader(ManagedRace managedRace, LoadClient callback); - - /** - * Creates a new {@link LoaderCallbacks} object for loading {@link Competitor}s. - * - * @param callback - * {@link LoadClient} implementing your data handling code. - * @return {@link LoaderCallbacks} to be used in - * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or - * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. - */ - LoaderCallbacks>> createCompetitorsLoader(ManagedRace managedRace, - LoadClient> callback); - - /** - * Creates a new {@link LoaderCallbacks} object for loading a client's configuration. - * - * @param callback - * {@link LoadClient} implementing your data handling code. - * @return {@link LoaderCallbacks} to be used in - * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or - * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. - */ - LoaderCallbacks> createConfigurationLoader(DeviceConfigurationIdentifier identifier, - LoadClient callback); - - String getMapUrl(String baseUrl, ManagedRace race, String eventId, boolean showWindCharts, boolean showStreamlets, boolean showSimulation, - boolean showMapControls); - - /** - * Create a new {@link LoaderCallbacks} object for loading the race columns (e.g. factors) - * - * @param leaderboard - * @param race_column - * @param callback - * - * @return {@link LoaderCallbacks} to be used in - * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or - * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. - */ - LoaderCallbacks> createRaceColumnFactorLoader(LoadClient callback); -} +package com.sap.sailing.racecommittee.app.data; + +import java.io.Serializable; +import java.util.Collection; + +import com.sap.sailing.domain.base.Competitor; +import com.sap.sailing.domain.base.CourseArea; +import com.sap.sailing.domain.base.CourseBase; +import com.sap.sailing.domain.base.EventBase; +import com.sap.sailing.domain.base.Mark; +import com.sap.sailing.domain.base.configuration.DeviceConfiguration; +import com.sap.sailing.domain.base.configuration.DeviceConfigurationIdentifier; +import com.sap.sailing.domain.base.impl.RaceColumnFactorImpl; +import com.sap.sailing.racecommittee.app.data.clients.LoadClient; +import com.sap.sailing.racecommittee.app.data.loaders.DataLoaderResult; +import com.sap.sailing.racecommittee.app.domain.CoursePosition; +import com.sap.sailing.racecommittee.app.domain.ManagedRace; +import com.sap.sailing.racecommittee.app.ui.fragments.lists.PositionListFragment; + +import android.app.LoaderManager; +import android.app.LoaderManager.LoaderCallbacks; + +/** + *

+ * Interface for everything read related when working with data. + *

+ * + *

+ * The result values of this interface's methods are meant to be used in conjunction with the Android's + * {@link LoaderManager} facility. Everything that is loaded by this interface is stored and cached in the underlying + * {@link DataStore}. + *

+ * + *

+ * If there are cached results your {@link LoadClient}'s callback methods might be called twice (first cached results; + * afterwards remote results). See {@link LoadClient} for restrictions that apply to your data handling code. + *

+ */ +public interface ReadonlyDataManager { + + /** + * Gets the underlying data store. + * + * @return the {@link DataStore}. + */ + DataStore getDataStore(); + + /** + * Creates a new {@link LoaderCallbacks} object for loading {@link EventBase}s. + * + * @param callback + * {@link LoadClient} implementing your data handling code. + * @return {@link LoaderCallbacks} to be used in + * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or + * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. + */ + LoaderCallbacks>> createEventsLoader(LoadClient> callback); + + /** + * Creates a new {@link LoaderCallbacks} object for loading {@link CourseArea}s. + * + * @param callback + * {@link LoadClient} implementing your data handling code. + * @return {@link LoaderCallbacks} to be used in + * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or + * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. + */ + LoaderCallbacks>> createCourseAreasLoader(Serializable parentEventId, + LoadClient> callback); + + LoaderCallbacks>> createCourseAreasLoader(EventBase parentEvent, + LoadClient> callback); + + /** + * Creates a new {@link LoaderCallbacks} object for loading racing referee positions. + * + * @return {@link LoaderCallbacks} to be used in + * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or + * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. + */ + LoaderCallbacks>> createPositionLoader(PositionListFragment positionListFragment); + + /** + * Creates a new {@link LoaderCallbacks} object for loading {@link ManagedRace}s of a specific {@link CourseArea}. + * + * @param courseAreaId + * the {@link CourseArea}'s Identifier. + * @param callback + * {@link LoadClient} implementing your data handling code. + * @return {@link LoaderCallbacks} to be used in + * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or + * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. + */ + LoaderCallbacks>> createRacesLoader(Serializable courseAreaId, + LoadClient> callback); + + /** + * Creates a new {@link LoaderCallbacks} object for loading a race's {@link Mark}s. + * + * @param managedRace + * the {@link ManagedRace}. + * @param callback + * {@link LoadClient} implementing your data handling code. + * @return {@link LoaderCallbacks} to be used in + * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or + * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. + */ + LoaderCallbacks>> createMarksLoader(ManagedRace managedRace, LoadClient> callback); + + /** + * Creates a new {@link LoaderCallbacks} object for loading a race's {@link CourseBase}. + * + * @param managedRace + * the {@link ManagedRace}. + * @param callback + * {@link LoadClient} implementing your data handling code. + * @return {@link LoaderCallbacks} to be used in + * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or + * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. + */ + LoaderCallbacks> createCourseLoader(ManagedRace managedRace, LoadClient callback); + + /** + * Creates a new {@link LoaderCallbacks} object for loading {@link Competitor}s. + * + * @param callback + * {@link LoadClient} implementing your data handling code. + * @return {@link LoaderCallbacks} to be used in + * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or + * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. + */ + LoaderCallbacks>> createCompetitorsLoader(ManagedRace managedRace, + LoadClient> callback); + + /** + * Creates a new {@link LoaderCallbacks} object for loading a client's configuration. + * + * @param callback + * {@link LoadClient} implementing your data handling code. + * @return {@link LoaderCallbacks} to be used in + * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or + * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. + */ + LoaderCallbacks> createConfigurationLoader(DeviceConfigurationIdentifier identifier, + LoadClient callback); + + String getMapUrl(String baseUrl, ManagedRace race, String eventId, boolean showWindCharts, boolean showStreamlets, boolean showSimulation, + boolean showMapControls); + + /** + * Create a new {@link LoaderCallbacks} object for loading the race columns (e.g. factors) + * + * @param leaderboard + * @param race_column + * @param callback + * + * @return {@link LoaderCallbacks} to be used in + * {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or + * {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}. + */ + LoaderCallbacks> createRaceColumnFactorLoader(LoadClient callback); +}