Merge branch 'master' into ubilabs--rcapp--bug_3011

This commit is contained in:
Axel Uhl committed 2016-04-20 18:03:01 +02:00
commit d416b90b50
315 files changed
+28979 -10572

No files matched your search

@@ -1,33 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.sap.sailing.racecommittee.app"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="13"
android:versionName="1.5">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sap.sailing.racecommittee.app"
android:versionCode="14"
android:versionName="1.6">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="22"/>
android:targetSdkVersion="22" />
<permission
android:name="com.sap.sailing.racecommittee.app.MAPS_RECEIVE"
android:protectionLevel="signature"/>
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!--<uses-permission android:name="android.permission.CAMERA"/>-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />
<!--<uses-permission android:name="android.permission.RECORD_AUDIO"/>-->
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="com.sap.sailing.racecommittee.app.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!--<uses-permission android:name="com.sap.sailing.racecommittee.app.MAPS_RECEIVE" />-->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
android:required="true" />
<uses-feature
android:name="android.hardware.camera"
android:required="false"/>
android:required="false" />
<application
android:name=".RaceApplication"
@@ -39,17 +39,16 @@
android:theme="@style/AppTheme.Light">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDH-Dwy5yFlyBa2-VUgiZ3qGGUO8M_0MPY"/>
android:value="AIzaSyDH-Dwy5yFlyBa2-VUgiZ3qGGUO8M_0MPY" />
<activity
android:name=".ui.activities.LoginActivity">
<activity android:name=".ui.activities.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
@@ -68,41 +67,43 @@
android:pathPattern="apps/com.sap.sailing.racecommittee.app.apk"/>
</intent-filter>
</activity>
<activity android:name=".ui.activities.RacingActivity"/>
<activity android:name=".ui.activities.PasswordActivity"/>
<activity android:name=".ui.activities.PreferenceActivity">
<activity android:name=".ui.activities.RacingActivity" />
<activity android:name=".ui.activities.PasswordActivity" />
<activity
android:name=".ui.activities.PreferenceActivity"
android:theme="@style/PreferenceTheme">
<intent-filter>
<action android:name="android.intent.action.MANAGE_NETWORK_USAGE"/>
<action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".ui.activities.SystemInformationActivity"/>
<activity android:name=".ui.activities.SystemInformationActivity" />
<service
android:name=".services.RaceStateService"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="com.sap.sailing.racecommittee.app.action.startProcedureSpecificAction"/>
<action android:name="com.sap.sailing.racecommittee.app.action.startProcedureSpecificAction" />
</intent-filter>
</service>
<service
android:name="com.sap.sailing.android.shared.services.sending.MessageSendingService"
android:exported="false">
<intent-filter>
<action android:name="com.sap.sailing.racecommittee.app.action.sendSavedIntents"/>
<action android:name="com.sap.sailing.racecommittee.app.action.sendMessage"/>
<action android:name="com.sap.sailing.racecommittee.app.action.sendSavedIntents" />
<action android:name="com.sap.sailing.racecommittee.app.action.sendMessage" />
</intent-filter>
<meta-data
android:name="com.sap.sailing.android.shared.services.sending.messageRestorer"
android:value="com.sap.sailing.racecommittee.app.services.sending.EventRestorer"/>
android:value="com.sap.sailing.racecommittee.app.services.sending.EventRestorer" />
</service>
<receiver android:name="com.sap.sailing.android.shared.services.sending.ConnectivityChangedReceiver">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
</application>
Binary file not shown.

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/dark_sap_gray">
<item android:drawable="@color/dark_sap_gray_black_30"/>
</ripple>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/light_sap_gray">
<item android:drawable="@color/light_sap_gray_black_30"/>
</ripple>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/constant_light_gray_ripple">
<item android:drawable="@color/light_sap_gray_black_30"/>
</ripple>
Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 793 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 793 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 914 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1003 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- pressed -->
<item android:drawable="@color/dark_sap_gray" android:state_pressed="true" />
<!-- default -->
<item android:drawable="@color/dark_sap_gray_black_30" />
</selector>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- pressed -->
<item android:drawable="@color/light_sap_gray" android:state_pressed="true" />
<!-- default -->
<item android:drawable="@color/light_sap_gray_black_30" />
</selector>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/constant_light_gray"/>
<padding
android:left="5dp"
android:right="5dp"
android:top="@dimen/thin_line"/>
<corners
android:bottomLeftRadius="3dp"
android:bottomRightRadius="3dp"/>
</shape>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/constant_black"/>
<padding
android:left="5dp"
android:right="5dp"
android:top="@dimen/thin_line"/>
<corners
android:bottomLeftRadius="3dp"
android:bottomRightRadius="3dp"/>
</shape>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- pressed -->
<item android:drawable="@color/constant_light_gray_pressed" android:state_pressed="true" />
<!-- default -->
<item android:drawable="@color/light_sap_gray_black_30" />
</selector>
@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/sap_gray_black_30"
android:background="?attr/checkedItemBackground"
android:minHeight="@dimen/listView_row_min_height">
<ImageView
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/preference_item_height"
android:orientation="vertical"
android:background="@drawable/preference_background">
<TextView
android:id="@+id/preference_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:drawablePadding="32dp"
android:ellipsize="end"
android:maxLines="1"
android:paddingRight="8dp"
tools:text="@string/settings_category_general" />
<View
android:id="@+id/preference_line"
android:layout_width="match_parent"
android:layout_height="@dimen/thin_line"
android:layout_alignParentBottom="true"
android:layout_marginLeft="@dimen/preference_line_margin"
android:background="@color/light_sap_gray" />
</RelativeLayout>
@@ -1,37 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="#e1e1e0"
android:orientation="vertical">
<Button
android:id="@+id/buttonGeneral"
<android.support.v7.widget.RecyclerView
android:id="@+id/preference_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:tag="com.sap.sailing.racecommittee.app.ui.fragments.preference.GeneralPreferenceFragment"
android:text="@string/settings_category_general" />
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/preference_side_margin"
android:layout_marginRight="@dimen/preference_side_margin" />
<Button
android:id="@+id/buttonRegattaDefault"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/buttonGeneral"
android:tag="com.sap.sailing.racecommittee.app.ui.fragments.preference.RegattaPreferenceFragment"
android:text="@string/settings_category_regatta_defaults" />
<Button
android:id="@+id/buttonRegatta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/buttonRegattaDefault"
android:tag="com.sap.sailing.racecommittee.app.ui.fragments.preference.RegattaSpecificPreferenceFragment"
android:text="@string/settings_category_regattas" />
<Button
android:id="@+id/buttonCourseDesigner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/buttonRegatta"
android:tag="com.sap.sailing.racecommittee.app.ui.fragments.preference.CourseDesignerPreferenceFragment"
android:text="@string/settings_category_course_designer" />
</RelativeLayout>
</LinearLayout>
@@ -4,18 +4,16 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:background="?attr/sap_gray_black_30">
android:background="@color/light_sap_gray_black_30">
<include
android:id="@+id/toolbar_layout"
layout="@layout/toolbar" />
layout="@layout/toolbar_pref" />
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar_layout"
android:layout_marginLeft="@dimen/preference_margin"
android:layout_marginRight="@dimen/preference_margin" />
android:layout_below="@id/toolbar_layout" />
</RelativeLayout>
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/sap_gray_black_30">
<com.sap.sailing.racecommittee.app.ui.layouts.HeaderLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:headerText="@string/race_factor"/>
<RelativeLayout
android:id="@+id/button_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center_vertical">
<Button
android:id="@+id/set_column_factor"
style="?attr/button"
android:layout_width="@dimen/default_button_width"
android:layout_height="@dimen/default_button_height"
android:layout_centerInParent="true"
android:layout_margin="@dimen/unscheduled_confirm_button_margin"
android:text="@string/set_column_factor"
android:textSize="@dimen/textSize_18"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/button_bar"
android:layout_below="@id/header">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="@dimen/default_margin_twice">
<com.sap.sailing.racecommittee.app.ui.layouts.FloatLabelLayout
android:layout_width="200dp"
android:layout_height="wrap_content"
app:floatLabelPaddingLeft="@dimen/float_label_padding"
app:floatLabelTextAppearance="?attr/floatLabel">
<EditText
android:id="@+id/column_factor"
style="?attr/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="center_vertical"
android:hint="@string/race_factor"
android:inputType="numberDecimal"
android:textAppearance="?attr/textNormal"
android:textColor="?attr/white"/>
</com.sap.sailing.racecommittee.app.ui.layouts.FloatLabelLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/button_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center_vertical"
android:background="?attr/sap_gray_black_30">
<Button
android:id="@+id/set_column_factor"
style="?attr/buttonSolidNormal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="@dimen/unscheduled_confirm_button_margin"
android:text="@string/set_column_factor"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/button_bar"
android:background="?attr/sap_gray_black_30">
<com.sap.sailing.racecommittee.app.ui.layouts.FloatLabelLayout
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:floatLabelPaddingLeft="@dimen/float_label_padding"
app:floatLabelTextAppearance="?attr/floatLabel">
<EditText
android:id="@+id/column_factor"
style="?attr/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:hint="@string/race_factor"
android:inputType="numberDecimal"
android:textAppearance="?attr/textNormal"
android:textColor="?attr/white"/>
</com.sap.sailing.racecommittee.app.ui.layouts.FloatLabelLayout>
</RelativeLayout>
</RelativeLayout>
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/navigation_drawer_cell_height">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/navigation_drawer_cell_height">
<RelativeLayout
android:id="@+id/panel_right"
@@ -24,7 +24,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textAppearance="?attr/textXLarge"
tools:text="13:36" />
tools:text="13:36"/>
<TextView
android:id="@+id/race_started"
@@ -32,7 +32,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/race_started"
android:textAppearance="?attr/textXSmall" />
android:textAppearance="?attr/textXSmall"/>
<TextView
android:id="@+id/race_finished"
@@ -40,7 +40,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/race_finished"
android:textAppearance="?attr/textXSmall" />
android:textAppearance="?attr/textXSmall"/>
</LinearLayout>
<TextView
@@ -51,7 +51,7 @@
android:text="@string/race_unscheduled"
android:textColor="?attr/sap_light_gray"
android:textSize="@dimen/textSize_18"
android:visibility="gone" />
android:visibility="gone"/>
<ImageView
android:id="@+id/update_badge"
@@ -62,7 +62,7 @@
android:scaleType="matrix"
android:src="@drawable/updated"
android:visibility="gone"
tools:visibility="visible" />
tools:visibility="visible"/>
</RelativeLayout>
<RelativeLayout
@@ -76,7 +76,7 @@
android:id="@+id/race_marker"
android:layout_width="@dimen/obesity_line"
android:layout_height="match_parent"
android:src="?attr/marker_race" />
android:src="?attr/marker_race"/>
<LinearLayout
android:id="@+id/additional_info"
@@ -93,7 +93,7 @@
android:layout_margin="5dp"
android:src="?attr/link_24dp"
android:visibility="gone"
tools:visibility="visible" />
tools:visibility="visible"/>
<LinearLayout
android:id="@+id/race_flag"
@@ -110,7 +110,7 @@
android:layout_height="25dp"
android:layout_gravity="center"
android:scaleType="centerInside"
tools:src="@drawable/flag_alpha_64dp" />
tools:src="@drawable/flag_alpha_64dp"/>
<TextView
android:id="@+id/flag_timer"
@@ -119,7 +119,7 @@
android:layout_gravity="center"
android:drawableLeft="?attr/arrow_down"
android:textAppearance="?attr/textXSmall"
tools:text="01:12" />
tools:text="01:12"/>
</LinearLayout>
</LinearLayout>
@@ -141,7 +141,7 @@
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="?attr/textNormal"
tools:text="Race 3" />
tools:text="Race 3"/>
<TextView
android:id="@+id/depends_on"
@@ -152,13 +152,23 @@
android:textAppearance="?attr/textXSmall"
android:visibility="gone"
tools:text="5 minutes after ABC"
tools:visibility="visible" />
tools:visibility="visible"/>
</LinearLayout>
</RelativeLayout>
<TextView
android:id="@+id/explicit_factor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="?attr/factor_background"
android:textAppearance="?attr/textXSmall"
android:textColor="?attr/white_invert"
tools:text="x 3.5"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/thin_line"
android:layout_alignParentBottom="true"
android:background="?attr/black" />
android:background="?attr/black"/>
</RelativeLayout>
@@ -26,7 +26,7 @@
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/default_margin"
android:src="@drawable/ic_change_role_white_48dp"/>
android:src="@drawable/ic_refresh_white_48dp"/>
<TextView
android:id="@+id/regatta_data"
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
@@ -10,6 +10,15 @@
android:baselineAligned="false"
android:orientation="horizontal">
<com.sap.sailing.racecommittee.app.ui.views.PanelButton
android:id="@+id/button_factor"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
app:buttonHeader="@string/race_factor"
app:buttonType="typeValue"
app:linePosition="right" />
<com.sap.sailing.racecommittee.app.ui.views.PanelButton
android:id="@+id/button_course"
android:layout_width="0dp"
@@ -17,7 +26,7 @@
android:layout_weight="1"
app:buttonHeader="@string/course"
app:buttonType="typeValue"
app:linePosition="right"/>
app:linePosition="right" />
<com.sap.sailing.racecommittee.app.ui.views.PanelButton
android:id="@+id/button_wind"
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -16,7 +15,7 @@
android:layout_height="0dp"
android:layout_weight="1"
app:buttonHeader="@string/start_procedure"
app:buttonType="typeValue"/>
app:buttonType="typeValue" />
<com.sap.sailing.racecommittee.app.ui.views.PanelButton
android:id="@+id/button_mode"
@@ -51,6 +50,14 @@
app:buttonSwitch=""
app:buttonType="typeSwitch" />
<com.sap.sailing.racecommittee.app.ui.views.PanelButton
android:id="@+id/button_factor"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:buttonHeader="@string/race_factor"
app:buttonType="typeValue" />
<com.sap.sailing.racecommittee.app.ui.views.PanelButton
android:id="@+id/button_course"
android:layout_width="match_parent"
@@ -66,7 +73,6 @@
android:layout_weight="1"
app:buttonHeader="@string/wind"
app:buttonType="typeValue" />
</LinearLayout>
<View
@@ -70,7 +70,8 @@
android:id="@+id/competitor_score"
android:layout_width="@dimen/competitor_edit_width"
android:layout_height="wrap_content"
android:inputType="numberDecimal"/>
android:inputType="numberDecimal"
android:textColor="?attr/white"/>
</LinearLayout>
<LinearLayout
@@ -158,6 +159,7 @@
android:id="@+id/competitor_comment"
android:layout_width="@dimen/competitor_edit_width"
android:layout_height="wrap_content"
android:inputType="text"/>
android:inputType="text"
android:textColor="?attr/white"/>
</LinearLayout>
</LinearLayout>
@@ -70,6 +70,7 @@
android:layout_height="wrap_content"
android:hint="@string/score"
android:inputType="numberDecimal"
android:textColor="?attr/white"
android:textColorHint="@color/dialog_color_text"/>
</com.sap.sailing.racecommittee.app.ui.layouts.FloatLabelLayout>
</LinearLayout>
@@ -161,6 +162,7 @@
android:layout_height="wrap_content"
android:hint="@string/comment"
android:inputType="text"
android:textColor="?attr/white"
android:textColorHint="@color/dialog_color_text"/>
</com.sap.sailing.racecommittee.app.ui.layouts.FloatLabelLayout>
</LinearLayout>
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/toolbar_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ToolBarStyle"
app:popupTheme="@style/Theme.AppCompat.Light">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
tools:text="AUSWAHL"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:gravity="center"
android:minHeight="?attr/actionBarSize"
android:orientation="horizontal">
<ProgressBar
android:id="@+id/progress_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:indeterminate="true"
android:visibility="gone"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/thick_line"
android:layout_below="@id/toolbar"
android:background="@color/sap_yellow"/>
</RelativeLayout>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/toolbar_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ToolBarRacingStyle"
app:popupTheme="@style/Theme.AppCompat.Light"
app:titleTextAppearance="@style/RacingToolBarTitle">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
tools:text="AUSWAHL"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:gravity="center"
android:minHeight="?attr/actionBarSize"
android:orientation="horizontal">
<ProgressBar
android:id="@+id/progress_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:indeterminate="true"
android:visibility="gone"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/thick_line"
android:layout_below="@id/toolbar"
android:background="@color/sap_yellow"/>
</RelativeLayout>
@@ -3,17 +3,21 @@
<item
android:id="@+id/options_menu_reset"
android:title="@string/reset_race"/>
android:title="@string/reset_race" />
<item
android:id="@+id/options_menu_settings"
android:title="@string/options_menu_settings"/>
android:title="@string/options_menu_settings" />
<item
android:id="@+id/options_menu_info"
android:title="@string/options_menu_info"/>
android:title="@string/options_menu_info" />
<item
android:id="@+id/options_menu_role"
android:title="@string/options_menu_role" />
<item
android:id="@+id/options_menu_logout"
android:title="@string/logout"/>
android:title="@string/logout" />
</menu>
@@ -437,6 +437,8 @@
<string name="preference_allow_dependent_races_header">Relative Startzeit</string>
<string name="preference_allow_dependent_races_description">Aktiviert relative Startzeiten zwischen Rennen</string>
<string name="preference_dependent_races_offset_header">Standard Offset der relativen Startzeit (Minuten)</string>
<string name="preference_allow_edit_race_factor_header">Rennfaktor ändern</string>
<string name="preference_allow_edit_race_factor_description">Rennleiter können den Rennfaktor je Rennen ändern</string>
<string name="error_finished_time">Die ausgewählte Zielzeit liegt vor der Zeit, der ersten Schiffeinfahrt. Bitte überprüfe die Uhrzeit.</string>
<string name="error_finishing_time">Die ausgewählte Zeit is vor dem Rennstart. Bitte überprüfe die Uhrzeit.</string>
<string name="error_time_in_future">Die ausgewählte Zeit liegt in der Zukunft. Bitte überprüfe die Uhrzeit.</string>
@@ -500,9 +502,14 @@
<string name="preference_non_public_events_header">Zeige nicht öffentliche Events</string>
<string name="preference_non_public_events_summary">Lade alle Events, auch die nicht öffentlichen.</string>
<string name="race_factor">Faktor</string>
<string name="options_menu_role">Rolle wechseln</string>
<string name="reload_config">Konfiguration vom Server laden</string>
<string name="abort_title">Rennen abbrechen</string>
<string name="abort_hint">Welche laufenden Rennen möchten Sie abbrechen?</string>
<string name="abort_dismiss">Verwerfen</string>
<string name="set_column_factor">Setze Faktor</string>
<string name="set_factor_error">Beim Setzen des Faktors ist ein Fehler aufgetreten: %s</string>
</resources>
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="preference_columns" format="integer" type="integer">2</item>
<dimen name="navigation_drawer_width">500dp</dimen>
<dimen name="side_button_lockSize">16dp</dimen>
@@ -17,6 +17,10 @@
<dimen name="switch_height">40dp</dimen>
<dimen name="switch_padding">16dp</dimen>
<dimen name="preference_margin">16dp</dimen>
<dimen name="preference_line_margin">0dp</dimen>
<item name="preference_columns" format="integer" type="integer">1</item>
<!-- race state dependent -->
<!-- login -->
<dimen name="login_text_size_small">@dimen/textSize_22</dimen>
@@ -15,8 +15,6 @@
<dimen name="header_line">@dimen/thick_line</dimen>
<dimen name="preference_margin">0dp</dimen>
<dimen name="panel_text_padding">5dp</dimen>
<dimen name="textSize_14">14sp</dimen> <!-- XXSmall -->
@@ -48,6 +46,9 @@
<dimen name="flags">96dp</dimen>
<dimen name="preference_side_margin">72dp</dimen>
<item name="preference_columns" format="integer" type="integer">2</item>
<!-- custom dimens (float, integer) -->
<item name="picker_scale" format="float" type="integer">1.55</item>
<item name="flag_size" format="integer" type="integer">48</item>
@@ -14,8 +14,10 @@
<item name="race_panel_time" type="layout">@layout/race_panel_time_xlarge</item>
<item name="race_positioning" type="layout">@layout/race_tracking_list_normal</item>
<item name="race_schedule_button" type="layout">@layout/race_schedule_button_xlarge</item>
<item name="race_column_factor" type="layout">@layout/race_column_factor_normal</item>
<item name="race_schedule_procedure_pathfinder" type="layout">@layout/race_schedule_procedure_pathfinder_xlarge</item>
<item name="race_schedule_procedure_timing" type="layout">@layout/race_schedule_procedure_timing_xlarge</item>
<item name="toolbar" type="layout">@layout/toolbar_xlarge</item>
<item name="toolbar_pref" type="layout">@layout/toolbar_pref_xlarge</item>
</resources>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="PreferenceTheme" parent="PreferenceBase">
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="PreferenceTheme" parent="PreferenceBase">
<item name="android:colorPrimary">@color/light_colorPrimary</item>
<item name="android:colorPrimaryDark">@color/light_colorPrimaryDark</item>
<item name="android:colorAccent">@color/light_colorAccent</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
@@ -9,6 +9,8 @@
<item name="android:windowTranslucentStatus">true</item>
<item name="android:alertDialogTheme">@style/AppTheme.Dark.AlertDialog.v21</item>
<item name="checkedItemBackground">@drawable/checked_item_background_dark_ripple</item>
</style>
<style name="AppTheme.Dark.AlertDialog.v21" parent="Theme.AppCompat.Light.Dialog">
@@ -10,6 +10,8 @@
<item name="android:windowTranslucentStatus">true</item>
<item name="android:alertDialogTheme">@style/AppTheme.Light.AlertDialog.v21</item>
<item name="checkedItemBackground">@drawable/checked_item_background_light_ripple</item>
</style>
<style name="AppTheme.Light.AlertDialog.v21" parent="Theme.AppCompat.Light.Dialog">
@@ -21,6 +21,7 @@
<attr name="buttonSolidXSmall" format="reference"/>
<attr name="buttonSolidSmall" format="reference"/>
<attr name="buttonSolidNormal" format="reference"/>
<attr name="checkedItemBackground" format="reference"/>
<attr name="round" format="reference"/>
<attr name="round_transparent" format="reference"/>
<attr name="text" format="reference"/>
@@ -38,6 +39,8 @@
<attr name="editText" format="reference"/>
<attr name="floatLabel" format="reference"/>
<attr name="factor_background" format="reference"/>
<!-- drawable -->
<attr name="add" format="reference"/>
<attr name="access_time_18dp" format="reference"/>
@@ -16,8 +16,6 @@
<dimen name="header_line">@dimen/thin_line</dimen>
<dimen name="preference_margin">0dp</dimen>
<dimen name="panel_text_padding">5dp</dimen>
<dimen name="thin_line">1dp</dimen>
@@ -104,6 +102,12 @@
<dimen name="switch_height">32dp</dimen>
<dimen name="switch_padding">8dp</dimen>
<dimen name="preference_side_margin">0dp</dimen>
<dimen name="preference_margin">0dp</dimen>
<dimen name="preference_line_margin">72dp</dimen>
<dimen name="preference_item_height">72dp</dimen>
<item name="preference_columns" format="integer" type="integer">1</item>
<!-- race state dependent -->
<!-- login -->
<dimen name="login_text_size_small">@dimen/textSize_18</dimen>
@@ -97,6 +97,8 @@
<bool name="preference_allow_dependent_races_default">true</bool>
<string name="preference_dependent_races_offset_key" translatable="false">dependentRacesOffset</string>
<integer name="preference_dependent_races_offset_default">5</integer>
<string name="preference_allow_edit_race_factor_key" translatable="false">raceFactor</string>
<bool name="preference_allow_edit_race_factor_default">true</bool>
<string name="preference_allow_demo_key" translatable="false">allow_demo</string>
<bool name="preference_allow_demo_default">false</bool>
@@ -121,4 +123,8 @@
<string name="preference_non_public_events_key" translatable="false">show_non_public_events</string>
<bool name="preference_non_public_events_default">false</bool>
<string name="preference_config_needs_refresh_key" translatable="false">config_refresh</string>
<bool name="preference_config_needs_refresh_default" translatable="false">true</bool>
</resources>
@@ -10,6 +10,7 @@
<item name="login_listviews_button" type="layout">@layout/login_listviews_button_normal</item>
<item name="photo_list_button" type="layout">@layout/photo_list_button_normal</item>
<item name="photo_list_item" type="layout">@layout/photo_list_item_normal</item>
<item name="race_column_factor" type="layout">@layout/race_column_factor_normal</item>
<item name="race_finished" type="layout">@layout/race_finished_normal</item>
<item name="race_finished_buttons" type="layout">@layout/race_finished_buttons_hor</item>
<item name="race_finished_desc" type="layout">@layout/race_finished_desc_hor</item>
@@ -29,6 +30,7 @@
<item name="race_schedule_start_time" type="layout">@layout/race_schedule_start_time_normal</item>
<item name="race_time_picker" type="layout">@layout/race_time_picker_normal</item>
<item name="toolbar" type="layout">@layout/toolbar_normal</item>
<item name="toolbar_pref" type="layout">@layout/toolbar_pref_normal</item>
<item name="wind_view" type="layout">@layout/wind_view_normal</item>
<item name="system_information_view" type="layout">@layout/system_information_view_normal</item>
@@ -459,6 +459,8 @@
<string name="preference_allow_dependent_races_header">Relative Start Time (Minutes)</string>
<string name="preference_allow_dependent_races_description">Enable Relative Start Time between Races</string>
<string name="preference_dependent_races_offset_header">Default Relative Start Time Offset</string>
<string name="preference_allow_edit_race_factor_header">Race factor change</string>
<string name="preference_allow_edit_race_factor_description">Race managers can change the race factor per race</string>
<string name="error_finished_time">The given finish time is earlier than the first finisher time. Please recheck the time.</string>
<string name="error_finishing_time">The selected time is before the race start.</string>
<string name="error_time_in_future">The given time is in future. Please recheck the time.</string>
@@ -528,8 +530,14 @@
<string name="preference_non_public_events_header">Show Non Public Events</string>
<string name="preference_non_public_events_summary">Load all events including the no public one.</string>
<string name="race_factor">Factor</string>
<string name="options_menu_role">Change Regatta</string>
<string name="reload_config">Reload Configuration from Server</string>
<string name="abort_title">Abort Races</string>
<string name="abort_hint">Which running races do you want to abort?</string>
<string name="abort_dismiss">Dismiss</string>
<string name="race_factor_format" translatable="false">x #.####</string>
<string name="set_column_factor">Set Factor</string>
<string name="set_factor_error">There was an error while setting the factor: %s</string>
</resources>
@@ -22,6 +22,14 @@
<item name="android:textColor">@color/dialog_color_header</item>
</style>
<style name="PreferenceTheme" parent="PreferenceBase"/>
<style name="PreferenceBase" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/light_colorPrimary</item>
<item name="colorPrimaryDark">@color/light_colorPrimaryDark</item>
<item name="colorAccent">@color/light_colorAccent</item>
</style>
<style name="ToolBarStyle" parent="@style/ThemeOverlay.AppCompat.Dark">
<item name="android:textColorSecondary">@color/constant_white</item>
</style>
@@ -34,9 +42,9 @@
<style name="DrawerButton" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="thickness">4dp</item>
<!--
<!--
<item name="barSize">30dp</item>
-->
-->
<item name="gapBetweenBars">6dp</item>
<item name="drawableSize">32dp</item>
<item name="spinBars">false</item>
@@ -36,6 +36,7 @@
<item name="buttonSolidXSmall">@style/AppTheme.Dark.Button.XSmall</item>
<item name="buttonSolidSmall">@style/AppTheme.Dark.Button.Small</item>
<item name="buttonSolidNormal">@style/AppTheme.Dark.Button.Normal</item>
<item name="checkedItemBackground">@drawable/checked_item_background_dark</item>
<item name="round">@style/AppTheme.Dark.Round</item>
<item name="round_transparent">@style/AppTheme.Dark.RoundTransparent</item>
<item name="text">@style/AppTheme.Dark.Text</item>
@@ -51,6 +52,8 @@
<item name="textPanelHeader">@style/AppTheme.Dark.Text.PanelHeader</item>
<item name="floatLabel">@style/AppTheme.Dark.Text.FloatLabel</item>
<item name="factor_background">@drawable/factor_background_dark</item>
<!-- drawable -->
<item name="add">@drawable/ic_add_dark</item>
<item name="access_time_18dp">@drawable/ic_access_time_white_18dp</item>
@@ -28,16 +28,16 @@
<!-- colors -->
<item name="black">@color/light_black</item>
<item name="sap_blue_1">@color/constant_sap_blue_1</item>
<item name="sap_gray">@color/light_sap_gray</item>
<item name="sap_gray">@color/light_sap_gray</item> <!-- ripple -->
<item name="sap_gray_black_20">@color/light_sap_gray_black_20</item>
<item name="sap_gray_black_30">@color/light_sap_gray_black_30</item>
<item name="sap_gray_black_30">@color/light_sap_gray_black_30</item> <!-- bg -->
<item name="sap_gray_black_40">@color/light_sap_gray_black_40</item>
<item name="sap_gray_white_10">@color/light_sap_gray_white_10</item>
<item name="sap_gray_white_20">@color/light_sap_gray_white_20</item>
<item name="sap_light_gray">@color/light_sap_light_gray</item>
<item name="sap_light_gray">@color/light_sap_light_gray</item> <!-- unselected -->
<item name="sap_red_1">@color/constant_sap_red_1</item>
<item name="sap_yellow_1">@color/constant_sap_yellow_1</item>
<item name="white">@color/white_light</item>
<item name="white">@color/white_light</item> <!-- selected / init -->
<item name="white_invert">@color/constant_white</item>
<!-- styles -->
@@ -45,6 +45,7 @@
<item name="buttonSolidXSmall">@style/AppTheme.Light.Button.XSmall</item>
<item name="buttonSolidSmall">@style/AppTheme.Light.Button.Small</item>
<item name="buttonSolidNormal">@style/AppTheme.Light.Button.Normal</item>
<item name="checkedItemBackground">@drawable/checked_item_background_light</item>
<item name="round">@style/AppTheme.Light.Round</item>
<item name="round_transparent">@style/AppTheme.Light.RoundTransparent</item>
<item name="text">@style/AppTheme.Light.Text</item>
@@ -60,6 +61,8 @@
<item name="textPanelHeader">@style/AppTheme.Light.Text.PanelHeader</item>
<item name="floatLabel">@style/AppTheme.Light.Text.FloatLabel</item>
<item name="factor_background">@drawable/factor_background_light</item>
<!-- drawables -->
<item name="add">@drawable/ic_add_light</item>
<item name="access_time_18dp">@drawable/ic_access_time_black_18dp</item>
@@ -7,33 +7,39 @@
android:defaultValue="@string/preference_racing_procedure_override_default"
android:key="@string/preference_racing_procedure_override_key"
android:summary="@string/override_default_start_procedure_type_select_description"
android:title="@string/override_default_start_procedure_type_select_header"/>
android:title="@string/override_default_start_procedure_type_select_header" />
<ListPreference
android:defaultValue="@string/preference_course_designer_override_default"
android:key="@string/preference_course_designer_override_key"
android:title="@string/override_default_course_designer_type_select_header"/>
android:title="@string/override_default_course_designer_type_select_header" />
<CheckBoxPreference
android:defaultValue="@bool/preference_allow_dependent_races_default"
android:key="@string/preference_allow_dependent_races_key"
android:summary="@string/preference_allow_dependent_races_description"
android:title="@string/preference_allow_dependent_races_header"/>
android:title="@string/preference_allow_dependent_races_header" />
<com.sap.sailing.racecommittee.app.ui.views.IntegerEditTextPreference
android:defaultValue="@integer/preference_dependent_races_offset_default"
android:key="@string/preference_dependent_races_offset_key"
android:numeric="integer"
android:title="@string/preference_dependent_races_offset_header"/>
android:title="@string/preference_dependent_races_offset_header" />
<SwitchPreference
android:defaultValue="@bool/preference_heading_with_declination_subtracted_default"
android:key="@string/preference_heading_with_declination_subtracted_key"
android:switchTextOn="@string/preference_heading_with_declination_subtracted_is_enabled"
android:switchTextOff="@string/preference_heading_with_declination_subtracted_is_disabled"
android:summaryOn="@string/preference_heading_with_declination_subtracted_summary_is_enabled"
android:summaryOff="@string/preference_heading_with_declination_subtracted_summary_is_disabled"
android:title="@string/preference_heading_with_declination_subtracted_enabled"/>
android:summaryOn="@string/preference_heading_with_declination_subtracted_summary_is_enabled"
android:switchTextOff="@string/preference_heading_with_declination_subtracted_is_disabled"
android:switchTextOn="@string/preference_heading_with_declination_subtracted_is_enabled"
android:title="@string/preference_heading_with_declination_subtracted_enabled" />
<CheckBoxPreference
android:defaultValue="@bool/preference_allow_edit_race_factor_default"
android:key="@string/preference_allow_edit_race_factor_key"
android:summary="@string/preference_allow_edit_race_factor_description"
android:title="@string/preference_allow_edit_race_factor_header" />
</PreferenceCategory>
<PreferenceCategory android:title="RRS26">
@@ -42,13 +48,13 @@
android:defaultValue="@string/preference_racing_procedure_classflag_default"
android:key="@string/preference_racing_procedure_rrs26_classflag_key"
android:summary="@string/empty"
android:title="@string/preference_racing_procedure_classflag_header"/>
android:title="@string/preference_racing_procedure_classflag_header" />
<CheckBoxPreference
android:defaultValue="@bool/preference_racing_procedure_rrs26_hasxray_default"
android:key="@string/preference_racing_procedure_rrs26_hasxray_key"
android:summary="@string/preference_racing_procedure_hasxray_description"
android:title="@string/preference_racing_procedure_hasxray_header"/>
android:title="@string/preference_racing_procedure_hasxray_header" />
<CheckBoxPreference
android:defaultValue="@bool/preference_racing_procedure_rrs26_resultentryenabled_default"
@@ -60,7 +66,7 @@
android:defaultValue="@array/preference_racing_procedure_rrs26_startmode_flags_default"
android:key="@string/preference_racing_procedure_rrs26_startmode_flags_key"
android:summary="@string/empty"
android:title="@string/preference_racing_procedure_rrs26_startmode_flags_header"/>
android:title="@string/preference_racing_procedure_rrs26_startmode_flags_header" />
</PreferenceCategory>
@@ -70,13 +76,13 @@
android:defaultValue="@string/preference_racing_procedure_classflag_default"
android:key="@string/preference_racing_procedure_gatestart_classflag_key"
android:summary="@string/empty"
android:title="@string/preference_racing_procedure_classflag_header"/>
android:title="@string/preference_racing_procedure_classflag_header" />
<CheckBoxPreference
android:defaultValue="@bool/preference_racing_procedure_gatestart_hasxray_default"
android:key="@string/preference_racing_procedure_gatestart_hasxray_key"
android:summary="@string/preference_racing_procedure_hasxray_description"
android:title="@string/preference_racing_procedure_hasxray_header"/>
android:title="@string/preference_racing_procedure_hasxray_header" />
<CheckBoxPreference
android:defaultValue="@bool/preference_racing_procedure_gatestart_resultentryenabled_default"
@@ -88,13 +94,13 @@
android:defaultValue="@bool/preference_racing_procedure_gatestart_haspathfinder_default"
android:key="@string/preference_racing_procedure_gatestart_haspathfinder_key"
android:summary="@string/preference_racing_procedure_gatestart_haspathfinder_description"
android:title="@string/preference_racing_procedure_gatestart_haspathfinder_header"/>
android:title="@string/preference_racing_procedure_gatestart_haspathfinder_header" />
<CheckBoxPreference
android:defaultValue="@bool/preference_racing_procedure_gatestart_hasadditionalgolfdowntime_default"
android:key="@string/preference_racing_procedure_gatestart_hasadditionalgolfdowntime_key"
android:summary="@string/preference_racing_procedure_gatestart_hasadditionalgolfdowntime_description"
android:title="@string/preference_racing_procedure_gatestart_hasadditionalgolfdowntime_header"/>
android:title="@string/preference_racing_procedure_gatestart_hasadditionalgolfdowntime_header" />
</PreferenceCategory>
@@ -104,13 +110,13 @@
android:defaultValue="@string/preference_racing_procedure_classflag_default"
android:key="@string/preference_racing_procedure_ess_classflag_key"
android:summary="@string/empty"
android:title="@string/preference_racing_procedure_classflag_header"/>
android:title="@string/preference_racing_procedure_classflag_header" />
<CheckBoxPreference
android:defaultValue="@bool/preference_racing_procedure_ess_hasxray_default"
android:key="@string/preference_racing_procedure_ess_hasxray_key"
android:summary="@string/preference_racing_procedure_hasxray_description"
android:title="@string/preference_racing_procedure_hasxray_header"/>
android:title="@string/preference_racing_procedure_hasxray_header" />
<CheckBoxPreference
android:defaultValue="@bool/preference_racing_procedure_ess_resultentryenabled_default"
@@ -126,13 +132,13 @@
android:defaultValue="@string/preference_racing_procedure_classflag_default"
android:key="@string/preference_racing_procedure_basic_classflag_key"
android:summary="@string/empty"
android:title="@string/preference_racing_procedure_classflag_header"/>
android:title="@string/preference_racing_procedure_classflag_header" />
<CheckBoxPreference
android:defaultValue="@bool/preference_racing_procedure_basic_hasxray_default"
android:key="@string/preference_racing_procedure_basic_hasxray_key"
android:summary="@string/preference_racing_procedure_hasxray_description"
android:title="@string/preference_racing_procedure_hasxray_header"/>
android:title="@string/preference_racing_procedure_hasxray_header" />
<CheckBoxPreference
android:defaultValue="@bool/preference_racing_procedure_basic_resultentryenabled_default"
@@ -148,13 +154,13 @@
android:defaultValue="@string/preference_racing_procedure_classflag_default"
android:key="@string/preference_racing_procedure_league_classflag_key"
android:summary="@string/empty"
android:title="@string/preference_racing_procedure_classflag_header"/>
android:title="@string/preference_racing_procedure_classflag_header" />
<CheckBoxPreference
android:defaultValue="@bool/preference_racing_procedure_league_hasxray_default"
android:key="@string/preference_racing_procedure_league_hasxray_key"
android:summary="@string/preference_racing_procedure_hasxray_description"
android:title="@string/preference_racing_procedure_hasxray_header"/>
android:title="@string/preference_racing_procedure_hasxray_header" />
<CheckBoxPreference
android:defaultValue="@bool/preference_racing_procedure_league_resultentryenabled_default"
@@ -22,11 +22,15 @@ public class AppConstants {
public final static String DARK_THEME = "dark";
public final static String LIGHT_THEME = "light";
public final static String INTENT_ACTION_RESET = PACKAGE_NAME + ".action.reset";
public final static String INTENT_ACTION_REGISTER_RACE = PACKAGE_NAME + ".action.registerRace";
public final static String INTENT_ACTION_CLEAR_RACES = PACKAGE_NAME + ".action.clearRaces";
public final static String INTENT_ACTION_ALARM_ACTION = PACKAGE_NAME + ".action.alarmAction";
public final static String INTENT_ACTION_START_PROCEDURE_SPECIFIC_ACTION = PACKAGE_NAME + ".action.startProcedureSpecificAction";
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_REGISTER_RACE = INTENT_ACTION + ".registerRace";
public final static String INTENT_ACTION_UNREGISTER_RACE = INTENT_ACTION + ".unregisterRace";
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";
// Login activity
public final static String EventIdTag = "EventId";
@@ -41,6 +45,7 @@ public class AppConstants {
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";
@@ -66,10 +71,12 @@ public class AppConstants {
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";
@@ -61,6 +61,7 @@ public class AppPreferences {
public static AppPreferences on(Context context, String preferenceName) {
return new AppPreferences(context, preferenceName);
}
protected final Context context;
private OnSharedPreferenceChangeListener pollingActiveChangedListener = new OnSharedPreferenceChangeListener() {
@@ -76,18 +77,20 @@ public class AppPreferences {
private Set<PollingActiveChangedListener> pollingActiveChangedListeners = new HashSet<>();
protected final SharedPreferences preferences;
protected AppPreferences(Context context) {
this.context = context.getApplicationContext();
this.preferences = PreferenceManager.getDefaultSharedPreferences(context);
}
public AppPreferences(Context context, String preferenceName) {
this.context = context.getApplicationContext();
this.preferences = context.getSharedPreferences(preferenceName, Context.MODE_PRIVATE);
}
public void setAuthor(AbstractLogEventAuthor author) {
preferences.edit().putString(HIDDEN_PREFERENCE_AUTHOR_NAME, author.getName()).commit();
preferences.edit().putInt(HIDDEN_PREFERENCE_AUTHOR_PRIORITY, author.getPriority()).commit();
preferences.edit().putString(HIDDEN_PREFERENCE_AUTHOR_NAME, author.getName()).putInt(HIDDEN_PREFERENCE_AUTHOR_PRIORITY, author.getPriority())
.commit();
}
public AbstractLogEventAuthor getAuthor() {
@@ -134,8 +137,7 @@ public class AppPreferences {
}
public RacingProcedureType getDefaultRacingProcedureType() {
String defaultStartProcedureType = preferences.getString(
key(R.string.preference_racing_procedure_override_key), "");
String defaultStartProcedureType = preferences.getString(key(R.string.preference_racing_procedure_override_key), "");
return RacingProcedureType.valueOf(defaultStartProcedureType);
}
@@ -156,24 +158,24 @@ public class AppPreferences {
return preferences.getBoolean(key(R.string.preference_racing_procedure_gatestart_haspathfinder_key), true);
}
public LoginType getLoginType() {
int type = preferences.getInt(HIDDEN_PREFERENCE_LOGIN_TYPE, -1);
switch( type ){
case 0:{
return LoginType.NONE;
}
case 1:{
return LoginType.VIEWER;
}
case 2:{
return LoginType.OFFICER;
}
public LoginType getLoginType() {
int type = preferences.getInt(HIDDEN_PREFERENCE_LOGIN_TYPE, -1);
switch (type) {
case 0: {
return LoginType.NONE;
}
case 1: {
return LoginType.VIEWER;
}
case 2: {
return LoginType.OFFICER;
}
default:{
return LoginType.NONE;
}
}
}
default: {
return LoginType.NONE;
}
}
}
public String getMailRecipient() {
return preferences.getString(key(R.string.preference_mail_key), "");
@@ -205,18 +207,18 @@ public class AppPreferences {
private String getRacingProcedureClassFlagKey(RacingProcedureType type) {
switch (type) {
case RRS26:
return key(R.string.preference_racing_procedure_rrs26_classflag_key);
case GateStart:
return key(R.string.preference_racing_procedure_gatestart_classflag_key);
case ESS:
return key(R.string.preference_racing_procedure_ess_classflag_key);
case BASIC:
return key(R.string.preference_racing_procedure_basic_classflag_key);
case LEAGUE:
return key(R.string.preference_racing_procedure_league_classflag_key);
default:
throw new IllegalArgumentException("Unknown racing procedure type.");
case RRS26:
return key(R.string.preference_racing_procedure_rrs26_classflag_key);
case GateStart:
return key(R.string.preference_racing_procedure_gatestart_classflag_key);
case ESS:
return key(R.string.preference_racing_procedure_ess_classflag_key);
case BASIC:
return key(R.string.preference_racing_procedure_basic_classflag_key);
case LEAGUE:
return key(R.string.preference_racing_procedure_league_classflag_key);
default:
throw new IllegalArgumentException("Unknown racing procedure type.");
}
}
@@ -227,18 +229,18 @@ public class AppPreferences {
private String getRacingProcedureHasIndividualRecallKey(RacingProcedureType type) {
switch (type) {
case RRS26:
return key(R.string.preference_racing_procedure_rrs26_hasxray_key);
case GateStart:
return key(R.string.preference_racing_procedure_gatestart_hasxray_key);
case ESS:
return key(R.string.preference_racing_procedure_ess_hasxray_key);
case BASIC:
return key(R.string.preference_racing_procedure_basic_hasxray_key);
case LEAGUE:
return key(R.string.preference_racing_procedure_league_hasxray_key);
default:
throw new IllegalArgumentException("Unknown racing procedure type.");
case RRS26:
return key(R.string.preference_racing_procedure_rrs26_hasxray_key);
case GateStart:
return key(R.string.preference_racing_procedure_gatestart_hasxray_key);
case ESS:
return key(R.string.preference_racing_procedure_ess_hasxray_key);
case BASIC:
return key(R.string.preference_racing_procedure_basic_hasxray_key);
case LEAGUE:
return key(R.string.preference_racing_procedure_league_hasxray_key);
default:
throw new IllegalArgumentException("Unknown racing procedure type.");
}
}
@@ -287,10 +289,10 @@ public class AppPreferences {
return Double.longBitsToDouble(windSpeedAsLong);
}
public LatLng getWindPosition(){
double lat = Double.longBitsToDouble(preferences.getLong(HIDDEN_PREFERENCE_WIND_LAT, 0));
double lng = Double.longBitsToDouble(preferences.getLong(HIDDEN_PREFERENCE_WIND_LNG, 0));
return new LatLng(lat,lng);
public LatLng getWindPosition() {
double lat = Double.longBitsToDouble(preferences.getLong(HIDDEN_PREFERENCE_WIND_LAT, 0));
double lng = Double.longBitsToDouble(preferences.getLong(HIDDEN_PREFERENCE_WIND_LNG, 0));
return new LatLng(lat, lng);
}
public boolean isPollingActive() {
@@ -319,9 +321,7 @@ public class AppPreferences {
}
public void setByNameCourseDesignerCourseNames(List<String> courseNames) {
preferences
.edit()
.putStringSet(key(R.string.preference_course_designer_by_name_course_names_key), new HashSet<>(courseNames)).commit();
preferences.edit().putStringSet(key(R.string.preference_course_designer_by_name_course_names_key), new HashSet<>(courseNames)).commit();
}
public void setCourseLayout(CourseLayouts courseLayout) {
@@ -338,51 +338,47 @@ public class AppPreferences {
}
public void setGateStartHasAdditionalGolfDownTime(boolean hasAdditionalGolfDownTime) {
preferences
.edit()
.putBoolean(key(R.string.preference_racing_procedure_gatestart_hasadditionalgolfdowntime_key), hasAdditionalGolfDownTime).commit();
preferences.edit().putBoolean(key(R.string.preference_racing_procedure_gatestart_hasadditionalgolfdowntime_key), hasAdditionalGolfDownTime)
.commit();
}
public void setGateStartHasPathfinder(boolean hasPathfinder) {
preferences.edit()
.putBoolean(key(R.string.preference_racing_procedure_gatestart_haspathfinder_key), hasPathfinder)
.commit();
preferences.edit().putBoolean(key(R.string.preference_racing_procedure_gatestart_haspathfinder_key), hasPathfinder).commit();
}
public void setLoginType(LoginType type) {
ExLog.i(getContext(), this.getClass().toString(), "setLoginType: "+ type);
public void setLoginType(LoginType type) {
ExLog.i(getContext(), this.getClass().toString(), "setLoginType: " + type);
Editor setEdit = preferences.edit();
switch( type ){
case NONE:{
setEdit.putInt(HIDDEN_PREFERENCE_LOGIN_TYPE, 0);
break;
}
case VIEWER:{
setEdit.putInt(HIDDEN_PREFERENCE_LOGIN_TYPE, 1);
break;
}
case OFFICER:{
setEdit.putInt(HIDDEN_PREFERENCE_LOGIN_TYPE, 2);
break;
}
switch (type) {
case NONE: {
setEdit.putInt(HIDDEN_PREFERENCE_LOGIN_TYPE, 0);
break;
}
case VIEWER: {
setEdit.putInt(HIDDEN_PREFERENCE_LOGIN_TYPE, 1);
break;
}
case OFFICER: {
setEdit.putInt(HIDDEN_PREFERENCE_LOGIN_TYPE, 2);
break;
}
default:{
break;
}
}
default: {
break;
}
}
setEdit.commit();
}
setEdit.commit();
}
public void setMailRecipient(String mail) {
preferences.edit().putString(key(R.string.preference_mail_key), mail).commit();
}
public void setManagedCourseAreaNames(List<String> courseAreaNames) {
preferences.edit()
.putStringSet(key(R.string.preference_course_areas_key), new HashSet<>(courseAreaNames)).commit();
preferences.edit().putStringSet(key(R.string.preference_course_areas_key), new HashSet<>(courseAreaNames)).commit();
}
public void setNumberOfRounds(NumberOfRounds numberOfRounds) {
@@ -410,15 +406,12 @@ public class AppPreferences {
for (Flags flag : flags) {
flagNames.add(flag.name());
}
preferences.edit().putStringSet(key(R.string.preference_racing_procedure_rrs26_startmode_flags_key), flagNames)
.commit();
preferences.edit().putStringSet(key(R.string.preference_racing_procedure_rrs26_startmode_flags_key), flagNames).commit();
}
public void setSendingActive(boolean activate) {
ExLog.i(getContext(), this.getClass().toString(), "setSendingActive: "+ activate);
preferences.edit()
.putBoolean(context.getResources().getString(R.string.preference_isSendingActive_key), activate)
.commit();
ExLog.i(getContext(), this.getClass().toString(), "setSendingActive: " + activate);
preferences.edit().putBoolean(context.getResources().getString(R.string.preference_isSendingActive_key), activate).commit();
}
public void setWindBearingFromDirection(double enteredWindBearing) {
@@ -434,10 +427,7 @@ public class AppPreferences {
public void setWindPosition(LatLng latLng) {
long lat = Double.doubleToLongBits(latLng.latitude);
long lng = Double.doubleToLongBits(latLng.longitude);
preferences.edit()
.putLong(HIDDEN_PREFERENCE_WIND_LAT, lat)
.putLong(HIDDEN_PREFERENCE_WIND_LNG, lng)
.commit();
preferences.edit().putLong(HIDDEN_PREFERENCE_WIND_LAT, lat).putLong(HIDDEN_PREFERENCE_WIND_LNG, lng).commit();
}
public void unregisterPollingActiveChangedListener(PollingActiveChangedListener listener) {
@@ -448,33 +438,33 @@ public class AppPreferences {
}
public boolean isDemoAllowed() {
return preferences.getBoolean(context.getString(R.string.preference_allow_demo_key),
context.getResources().getBoolean(R.bool.preference_allow_demo_default));
return preferences.getBoolean(context.getString(R.string.preference_allow_demo_key), context.getResources()
.getBoolean(R.bool.preference_allow_demo_default));
}
public boolean wakelockEnabled() {
return preferences.getBoolean(context.getString(R.string.preference_wakelock_key), context.getResources()
.getBoolean(R.bool.preference_wakelock_default));
return preferences
.getBoolean(context.getString(R.string.preference_wakelock_key), context.getResources().getBoolean(R.bool.preference_wakelock_default));
}
public boolean isOfflineMode() {
return preferences.getBoolean(context.getString(R.string.preference_offline_key), context.getResources()
.getBoolean(R.bool.preference_offline_default));
return preferences
.getBoolean(context.getString(R.string.preference_offline_key), context.getResources().getBoolean(R.bool.preference_offline_default));
}
public boolean isDependentRacesAllowed() {
return preferences.getBoolean(context.getString(R.string.preference_allow_dependent_races_key),
context.getResources().getBoolean(R.bool.preference_allow_dependent_races_default));
return preferences.getBoolean(context.getString(R.string.preference_allow_dependent_races_key), context.getResources()
.getBoolean(R.bool.preference_allow_dependent_races_default));
}
public int getDependentRacesOffset() {
return preferences.getInt(context.getString(R.string.preference_dependent_races_offset_key),
context.getResources().getInteger(R.integer.preference_dependent_races_offset_default));
return preferences.getInt(context.getString(R.string.preference_dependent_races_offset_key), context.getResources()
.getInteger(R.integer.preference_dependent_races_offset_default));
}
public String getTheme() {
return preferences.getString(context.getString(R.string.preference_theme_key), context.getResources()
.getString(R.string.preference_theme_default));
return preferences
.getString(context.getString(R.string.preference_theme_key), context.getResources().getString(R.string.preference_theme_default));
}
public void setAccessToken(String accessToken) {
@@ -483,15 +473,29 @@ public class AppPreferences {
public String getAccessToken() {
return preferences.getString(context.getString(R.string.preference_access_token_key), null);
}
}
public boolean isMagnetic() {
return preferences.getBoolean(context.getString(R.string.preference_heading_with_declination_subtracted_key),
context.getResources().getBoolean(R.bool.preference_heading_with_declination_subtracted_default));
return preferences.getBoolean(context.getString(R.string.preference_heading_with_declination_subtracted_key), context.getResources()
.getBoolean(R.bool.preference_heading_with_declination_subtracted_default));
}
public boolean isRaceFactorChangeAllow() {
return preferences.getBoolean(context.getString(R.string.preference_allow_edit_race_factor_key), context.getResources()
.getBoolean(R.bool.preference_allow_edit_race_factor_default));
}
public String showNonPublic() {
return preferences.getBoolean(context.getString(R.string.preference_non_public_events_key),
context.getResources().getBoolean(R.bool.preference_non_public_events_default)) ? "true" : "false";
return preferences.getBoolean(context.getString(R.string.preference_non_public_events_key), context.getResources()
.getBoolean(R.bool.preference_non_public_events_default)) ? "true" : "false";
}
public boolean needConfigRefresh() {
return preferences.getBoolean(context.getString(R.string.preference_config_needs_refresh_key), context.getResources()
.getBoolean(R.bool.preference_config_needs_refresh_default));
}
public void setNeedConfigRefresh(boolean refresh) {
preferences.edit().putBoolean(context.getString(R.string.preference_config_needs_refresh_key), refresh).commit();
}
}
@@ -63,4 +63,9 @@ public abstract class DataManager implements ReadonlyDataManager {
context.startService(intent);
}
public void stopService() {
Intent intent = new Intent(context, RaceStateService.class);
context.stopService(intent);
}
}
@@ -32,10 +32,12 @@ public interface DataStore {
Collection<ManagedRace> getRaces();
void addRace(ManagedRace race);
public ManagedRace getRace(String id);
public ManagedRace getRace(SimpleRaceLogIdentifier id);
public boolean hasRace(String id);
public boolean hasRace(SimpleRaceLogIdentifier id);
void addRace(int index, ManagedRace race);
void removeRace(ManagedRace race);
ManagedRace getRace(String id);
ManagedRace getRace(SimpleRaceLogIdentifier id);
boolean hasRace(String id);
boolean hasRace(SimpleRaceLogIdentifier id);
Collection<Mark> getMarks();
Mark getMark(Serializable id);
@@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@@ -61,18 +62,22 @@ public enum InMemoryDataStore implements DataStore {
* * * * * *
*/
@Override
public Collection<EventBase> getEvents() {
return eventsById.values();
}
@Override
public void addEvent(EventBase event) {
eventsById.put(event.getId(), event);
}
@Override
public EventBase getEvent(Serializable id) {
return eventsById.get(id);
}
@Override
public boolean hasEvent(Serializable id) {
return eventsById.containsKey(id);
}
@@ -83,6 +88,7 @@ public enum InMemoryDataStore implements DataStore {
* * * * * * * *
*/
@Override
public Collection<CourseArea> getCourseAreas(EventBase event) {
if (event.getVenue() != null) {
return CollectionUtils.newArrayList(event.getVenue().getCourseAreas());
@@ -102,6 +108,7 @@ public enum InMemoryDataStore implements DataStore {
return null;
}
@Override
public CourseArea getCourseArea(Serializable id) {
for (EventBase event : eventsById.values()) {
for (CourseArea courseArea : getCourseAreas(event)) {
@@ -113,6 +120,7 @@ public enum InMemoryDataStore implements DataStore {
return null;
}
@Override
public boolean hasCourseArea(Serializable id) {
for (EventBase event : eventsById.values()) {
for (CourseArea courseArea : getCourseAreas(event)) {
@@ -124,6 +132,7 @@ public enum InMemoryDataStore implements DataStore {
return false;
}
@Override
public void addCourseArea(EventBase event, CourseArea courseArea) {
if (event.getVenue() != null) {
event.getVenue().addCourseArea(courseArea);
@@ -136,14 +145,49 @@ public enum InMemoryDataStore implements DataStore {
* * * * * * * *
*/
@Override
public Collection<ManagedRace> getRaces() {
return managedRaceById.values();
}
@Override
public void addRace(ManagedRace race) {
managedRaceById.put(convertManagedRaceIdentifierToSimpleRaceLogIdentifier(race.getIdentifier()), race);
}
@Override
public void addRace(int index, ManagedRace race) {
if (index >= 0 && index <= managedRaceById.size()) {
LinkedHashMap<SimpleRaceLogIdentifier, ManagedRace> output = new LinkedHashMap<>();
int i = 0;
if (index == 0) {
output.put(convertManagedRaceIdentifierToSimpleRaceLogIdentifier(race.getIdentifier()), race);
output.putAll(managedRaceById);
} else {
for (Map.Entry<SimpleRaceLogIdentifier, ManagedRace> entry : managedRaceById.entrySet()) {
if (i == index) {
output.put(convertManagedRaceIdentifierToSimpleRaceLogIdentifier(race.getIdentifier()), race);
}
output.put(entry.getKey(), entry.getValue());
i++;
}
}
if (index == managedRaceById.size()) {
output.put(convertManagedRaceIdentifierToSimpleRaceLogIdentifier(race.getIdentifier()), race);
}
managedRaceById.clear();
managedRaceById.putAll(output);
output.clear();
} else {
throw new IndexOutOfBoundsException("index " + index + " must be greater than zero and less than size of the map");
}
}
@Override
public void removeRace(ManagedRace race) {
managedRaceById.remove(convertManagedRaceIdentifierToSimpleRaceLogIdentifier(race.getIdentifier()));
}
private SimpleRaceLogIdentifier convertManagedRaceIdentifierToSimpleRaceLogIdentifier(ManagedRaceIdentifier id) {
return new SimpleRaceLogIdentifierImpl(id.getRaceGroup().getName(), id.getRaceName(), id.getFleet().getName());
}
@@ -165,19 +209,17 @@ public enum InMemoryDataStore implements DataStore {
/**
* Parses a serialized version of a ManagedRaceIdentifier and creates a SimpleRaceLogIdentifier
* this is needed as the serialized version is passed around in the bundle context, but the
* InMemoryDataStore now has to use SimpleRaceLogIdentifier as key in the managedRaces HashMap in
* order to allow for retrieving a managed race with exclusively the information provided by a
* this is needed as the serialized version is passed around in the bundle context, but the
* InMemoryDataStore now has to use SimpleRaceLogIdentifier as key in the managedRaces HashMap in
* order to allow for retrieving a managed race with exclusively the information provided by a
* SimpleRaceLogIdentifier (which is less than the information provided by a ManagedRaceIdentifier)
*
* @param escapedId
* serialized version of a ManagedRaceIdentifier
* @return
* corresponding SimpleRaceLogIdentifier
*
* @param escapedId serialized version of a ManagedRaceIdentifier
* @return corresponding SimpleRaceLogIdentifier
*/
public SimpleRaceLogIdentifier parseManagedRaceLogIdentifier(final String escapedId) {
//Undo escaping
final Triple<String, String, String> id = FleetIdentifierImpl.unescape(escapedId);
final Triple<String, String, String> id = FleetIdentifierImpl.unescape(escapedId);
return new SimpleRaceLogIdentifierImpl(id.getA(), id.getB(), id.getC());
}
@@ -230,7 +272,7 @@ public enum InMemoryDataStore implements DataStore {
}
return raceGroups;
}
@Override
public RaceGroup getRaceGroup(String name) {
for (RaceGroup group : getRaceGroups()) {
@@ -1,257 +1,262 @@
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.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.<LeaderboardGroupBase> emptySet()));
dataStore.addEvent(new StrippedEventImpl("Extreme Sailing Series 2012 (Nice)", startDate, endDate, "Nice", true, UUID.randomUUID(), Collections.<LeaderboardGroupBase> emptySet()));
dataStore.addEvent(new StrippedEventImpl("Extreme Sailing Series 2012 (Rio)", startDate, endDate, "Rio", true, UUID.randomUUID(), Collections.<LeaderboardGroupBase> emptySet()));
EventBase newEvent = new StrippedEventImpl("Extreme Sailing Series 2013 (Muscat)", startDate, endDate, "Muscat", true, UUID.randomUUID(), Collections.<LeaderboardGroupBase> 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, null);
SeriesWithRows medal = new SeriesWithRowsImpl("Medal", true, null);
RaceGroup raceGroup = new RaceGroupImpl("ESS", /* displayName */ null, new BoatClassImpl("X40", false), null, Arrays.asList(qualifying,
medal), new EmptyRegattaConfiguration());
List<Competitor> competitors = new ArrayList<Competitor>();
competitors.add(new CompetitorImpl(UUID.randomUUID(), "SAP Extreme Sailing Team", Color.BLUE, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null));
competitors.add(new CompetitorImpl(UUID.randomUUID(), "The Wave Muscat", Color.LIGHT_GRAY, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null));
competitors.add(new CompetitorImpl(UUID.randomUUID(), "Red Bull Extreme Sailing Team", Color.RED, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null));
competitors.add(new CompetitorImpl(UUID.randomUUID(), "Team Korea", Color.GREEN, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null));
competitors.add(new CompetitorImpl(UUID.randomUUID(), "Realteam", Color.BLACK, null, null, null, null, /* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null));
RaceLog log = new RaceLogImpl(UUID.randomUUID());
final AbstractLogEventAuthor author = AppPreferences.on(context).getAuthor();
ConfigurationLoader<RegattaConfiguration> 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));
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));
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));
/*
* 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<DataLoaderResult<Collection<EventBase>>> createEventsLoader(
LoadClient<Collection<EventBase>> callback) {
return new ImmediateDataLoaderCallbacks<Collection<EventBase>>(context, callback,
new Callable<Collection<EventBase>>() {
@Override
public Collection<EventBase> call() throws Exception {
return dataStore.getEvents();
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<Collection<CourseArea>>> createCourseAreasLoader(
final Serializable parentEventId, LoadClient<Collection<CourseArea>> callback) {
return new ImmediateDataLoaderCallbacks<Collection<CourseArea>>(context, callback,
new Callable<Collection<CourseArea>>() {
@Override
public Collection<CourseArea> call() throws Exception {
return dataStore.getCourseAreas(dataStore.getEvent(parentEventId));
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<Collection<CourseArea>>> createCourseAreasLoader(
final EventBase parentEvent, LoadClient<Collection<CourseArea>> callback) {
// TODO Auto-generated method stub
return new ImmediateDataLoaderCallbacks<Collection<CourseArea>>(context, callback,
new Callable<Collection<CourseArea>>() {
@Override
public Collection<CourseArea> call() throws Exception {
return dataStore.getCourseAreas(parentEvent);
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<Collection<ManagedRace>>> createRacesLoader(Serializable courseAreaId,
LoadClient<Collection<ManagedRace>> callback) {
return new ImmediateDataLoaderCallbacks<Collection<ManagedRace>>(context, callback,
new Callable<Collection<ManagedRace>>() {
@Override
public Collection<ManagedRace> call() throws Exception {
return dataStore.getRaces();
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<Collection<Mark>>> createMarksLoader(ManagedRace managedRace,
LoadClient<Collection<Mark>> callback) {
return new ImmediateDataLoaderCallbacks<Collection<Mark>>(context, callback, new Callable<Collection<Mark>>() {
@Override
public Collection<Mark> call() throws Exception {
return dataStore.getMarks();
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<CourseBase>> createCourseLoader(final ManagedRace managedRace,
LoadClient<CourseBase> callback) {
return new ImmediateDataLoaderCallbacks<CourseBase>(context, callback, new Callable<CourseBase>() {
@Override
public CourseBase call() throws Exception {
return managedRace.getCourseOnServer();
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<Collection<Competitor>>> createCompetitorsLoader(
final ManagedRace managedRace, LoadClient<Collection<Competitor>> callback) {
return new ImmediateDataLoaderCallbacks<Collection<Competitor>>(context, callback,
new Callable<Collection<Competitor>>() {
@Override
public Collection<Competitor> call() throws Exception {
return managedRace.getCompetitors();
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<DeviceConfiguration>> createConfigurationLoader(
DeviceConfigurationIdentifier identifier, LoadClient<DeviceConfiguration> callback) {
return new ImmediateDataLoaderCallbacks<DeviceConfiguration>(context, callback,
new Callable<DeviceConfiguration>() {
@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<DataLoaderResult<Collection<CoursePosition>>> createPositionLoader(
PositionListFragment positionListFragment) {
// TODO Auto-generated method stub
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.<LeaderboardGroupBase> emptySet()));
dataStore.addEvent(new StrippedEventImpl("Extreme Sailing Series 2012 (Nice)", startDate, endDate, "Nice", true, UUID.randomUUID(), Collections.<LeaderboardGroupBase> emptySet()));
dataStore.addEvent(new StrippedEventImpl("Extreme Sailing Series 2012 (Rio)", startDate, endDate, "Rio", true, UUID.randomUUID(), Collections.<LeaderboardGroupBase> emptySet()));
EventBase newEvent = new StrippedEventImpl("Extreme Sailing Series 2013 (Muscat)", startDate, endDate, "Muscat", true, UUID.randomUUID(), Collections.<LeaderboardGroupBase> 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, null);
SeriesWithRows medal = new SeriesWithRowsImpl("Medal", true, null);
RaceGroup raceGroup = new RaceGroupImpl("ESS", /* displayName */ null, new BoatClassImpl("X40", false), null, Arrays.asList(qualifying,
medal), new EmptyRegattaConfiguration());
List<Competitor> competitors = new ArrayList<Competitor>();
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<RegattaConfiguration> 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));
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));
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));
/*
* 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<DataLoaderResult<Collection<EventBase>>> createEventsLoader(
LoadClient<Collection<EventBase>> callback) {
return new ImmediateDataLoaderCallbacks<Collection<EventBase>>(context, callback,
new Callable<Collection<EventBase>>() {
@Override
public Collection<EventBase> call() throws Exception {
return dataStore.getEvents();
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<Collection<CourseArea>>> createCourseAreasLoader(
final Serializable parentEventId, LoadClient<Collection<CourseArea>> callback) {
return new ImmediateDataLoaderCallbacks<Collection<CourseArea>>(context, callback,
new Callable<Collection<CourseArea>>() {
@Override
public Collection<CourseArea> call() throws Exception {
return dataStore.getCourseAreas(dataStore.getEvent(parentEventId));
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<Collection<CourseArea>>> createCourseAreasLoader(
final EventBase parentEvent, LoadClient<Collection<CourseArea>> callback) {
// TODO Auto-generated method stub
return new ImmediateDataLoaderCallbacks<Collection<CourseArea>>(context, callback,
new Callable<Collection<CourseArea>>() {
@Override
public Collection<CourseArea> call() throws Exception {
return dataStore.getCourseAreas(parentEvent);
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<Collection<ManagedRace>>> createRacesLoader(Serializable courseAreaId,
LoadClient<Collection<ManagedRace>> callback) {
return new ImmediateDataLoaderCallbacks<Collection<ManagedRace>>(context, callback,
new Callable<Collection<ManagedRace>>() {
@Override
public Collection<ManagedRace> call() throws Exception {
return dataStore.getRaces();
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<Collection<Mark>>> createMarksLoader(ManagedRace managedRace,
LoadClient<Collection<Mark>> callback) {
return new ImmediateDataLoaderCallbacks<Collection<Mark>>(context, callback, new Callable<Collection<Mark>>() {
@Override
public Collection<Mark> call() throws Exception {
return dataStore.getMarks();
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<CourseBase>> createCourseLoader(final ManagedRace managedRace,
LoadClient<CourseBase> callback) {
return new ImmediateDataLoaderCallbacks<CourseBase>(context, callback, new Callable<CourseBase>() {
@Override
public CourseBase call() throws Exception {
return managedRace.getCourseOnServer();
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<Collection<Competitor>>> createCompetitorsLoader(
final ManagedRace managedRace, LoadClient<Collection<Competitor>> callback) {
return new ImmediateDataLoaderCallbacks<Collection<Competitor>>(context, callback,
new Callable<Collection<Competitor>>() {
@Override
public Collection<Competitor> call() throws Exception {
return managedRace.getCompetitors();
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<DeviceConfiguration>> createConfigurationLoader(
DeviceConfigurationIdentifier identifier, LoadClient<DeviceConfiguration> callback) {
return new ImmediateDataLoaderCallbacks<DeviceConfiguration>(context, callback,
new Callable<DeviceConfiguration>() {
@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<DataLoaderResult<Collection<CoursePosition>>> createPositionLoader(
PositionListFragment positionListFragment) {
// TODO Auto-generated method stub
return null;
}
@Override
public LoaderCallbacks<DataLoaderResult<RaceColumnFactorImpl>> createRaceColumnFactorLoader(LoadClient<RaceColumnFactorImpl> callback) {
return null;
}
}
@@ -28,6 +28,7 @@ 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.impl.RaceColumnFactorImpl;
import com.sap.sailing.domain.common.racelog.RaceLogServletConstants;
import com.sap.sailing.racecommittee.app.AppConstants;
import com.sap.sailing.racecommittee.app.AppPreferences;
@@ -51,6 +52,7 @@ import com.sap.sailing.racecommittee.app.data.parsers.DeviceConfigurationParser;
import com.sap.sailing.racecommittee.app.data.parsers.EventsDataParser;
import com.sap.sailing.racecommittee.app.data.parsers.ManagedRacesDataParser;
import com.sap.sailing.racecommittee.app.data.parsers.MarksDataParser;
import com.sap.sailing.racecommittee.app.data.parsers.RaceColumnsParser;
import com.sap.sailing.racecommittee.app.domain.CoursePosition;
import com.sap.sailing.racecommittee.app.domain.ManagedRace;
import com.sap.sailing.racecommittee.app.domain.ManagedRaceIdentifier;
@@ -73,6 +75,7 @@ import com.sap.sailing.server.gateway.deserialization.impl.EventBaseJsonDeserial
import com.sap.sailing.server.gateway.deserialization.impl.LeaderboardGroupBaseJsonDeserializer;
import com.sap.sailing.server.gateway.deserialization.impl.NationalityJsonDeserializer;
import com.sap.sailing.server.gateway.deserialization.impl.PersonJsonDeserializer;
import com.sap.sailing.server.gateway.deserialization.impl.RaceColumnFactorJsonDeserializer;
import com.sap.sailing.server.gateway.deserialization.impl.RegattaConfigurationJsonDeserializer;
import com.sap.sailing.server.gateway.deserialization.impl.TeamJsonDeserializer;
import com.sap.sailing.server.gateway.deserialization.impl.VenueJsonDeserializer;
@@ -85,6 +88,9 @@ import com.sap.sse.common.Util;
public class OnlineDataManager extends DataManager {
private static final String TAG = OnlineDataManager.class.getName();
public static final String LEADERBOARD = "leaderboard";
public static final String RACE_COLUMN = "raceColumn";
protected OnlineDataManager(Context context, DataStore dataStore, SharedDomainFactory domainFactory) {
super(context, dataStore, domainFactory);
}
@@ -96,8 +102,9 @@ public class OnlineDataManager extends DataManager {
}
public void addRaces(Collection<ManagedRace> data) {
int index = 0;
for (ManagedRace race : data) {
dataStore.addRace(race);
dataStore.addRace(index++, race);
}
}
@@ -110,12 +117,11 @@ public class OnlineDataManager extends DataManager {
@Override
public LoaderCallbacks<DataLoaderResult<Collection<EventBase>>> createEventsLoader(
LoadClient<Collection<EventBase>> callback) {
return new DataLoaderCallbacks<Collection<EventBase>>(callback, new LoaderCreator<Collection<EventBase>>() {
return new DataLoaderCallbacks<>(callback, new LoaderCreator<Collection<EventBase>>() {
@Override
public Loader<DataLoaderResult<Collection<EventBase>>> create(int id, Bundle args) throws Exception {
ExLog.i(context, TAG, String.format("Creating Events-OnlineDataLoader %d", id));
EventBaseJsonDeserializer serializer = new EventBaseJsonDeserializer(new VenueJsonDeserializer(
new CourseAreaJsonDeserializer(domainFactory)), new LeaderboardGroupBaseJsonDeserializer());
EventBaseJsonDeserializer serializer = new EventBaseJsonDeserializer(new VenueJsonDeserializer(new CourseAreaJsonDeserializer(domainFactory)), new LeaderboardGroupBaseJsonDeserializer());
DataParser<Collection<EventBase>> parser = new EventsDataParser(serializer);
DataHandler<Collection<EventBase>> handler = new EventsDataHandler(OnlineDataManager.this);
@@ -123,8 +129,7 @@ public class OnlineDataManager extends DataManager {
List<Util.Pair<String, Object>> params = new ArrayList<>();
params.add(new Util.Pair<String, Object>("showNonPublic", AppPreferences.on(context).showNonPublic()));
URL url = UrlHelper.generateUrl(preferences.getServerBaseURL(), "/sailingserver/api/v1/events", params);
return new OnlineDataLoader<Collection<EventBase>>(context,
url, parser, handler);
return new OnlineDataLoader<>(context, url, parser, handler);
}
}, getContext());
}
@@ -132,57 +137,53 @@ public class OnlineDataManager extends DataManager {
@Override
public LoaderCallbacks<DataLoaderResult<Collection<CourseArea>>> createCourseAreasLoader(
final Serializable parentEventId, LoadClient<Collection<CourseArea>> callback) {
return new ImmediateDataLoaderCallbacks<Collection<CourseArea>>(context, callback,
new Callable<Collection<CourseArea>>() {
@Override
public Collection<CourseArea> call() throws Exception {
if (dataStore.hasEvent(parentEventId)) {
EventBase event = dataStore.getEvent(parentEventId);
return dataStore.getCourseAreas(event);
} else {
return new ImmediateDataLoaderCallbacks<>(context, callback, new Callable<Collection<CourseArea>>() {
@Override
public Collection<CourseArea> call() throws Exception {
if (dataStore.hasEvent(parentEventId)) {
EventBase event = dataStore.getEvent(parentEventId);
return dataStore.getCourseAreas(event);
} else {
// throw new DataLoadingException(String.format(
// "Unable to load course areas for unknown event %s.", parentEventId));
//TODO: Quickfix for #2889
return null;
}
}
});
//TODO: Quickfix for #2889
return null;
}
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<Collection<CourseArea>>> createCourseAreasLoader(
final EventBase parentEvent, LoadClient<Collection<CourseArea>> callback) {
// TODO Auto-generated method stub
return new ImmediateDataLoaderCallbacks<Collection<CourseArea>>(context, callback,
new Callable<Collection<CourseArea>>() {
@Override
public Collection<CourseArea> call() throws Exception {
return new ImmediateDataLoaderCallbacks<>(context, callback, new Callable<Collection<CourseArea>>() {
@Override
public Collection<CourseArea> call() throws Exception {
return dataStore.getCourseAreas(parentEvent);
return dataStore.getCourseAreas(parentEvent);
}
});
}
});
}
@Override
public LoaderCallbacks<DataLoaderResult<Collection<ManagedRace>>> createRacesLoader(
final Serializable courseAreaId, LoadClient<Collection<ManagedRace>> callback) {
return new DataLoaderCallbacks<Collection<ManagedRace>>(callback, new LoaderCreator<Collection<ManagedRace>>() {
return new DataLoaderCallbacks<>(callback, new LoaderCreator<Collection<ManagedRace>>() {
@Override
public Loader<DataLoaderResult<Collection<ManagedRace>>> create(int id, Bundle args) throws Exception {
ExLog.i(context, TAG, String.format("Creating races-OnlineDataLoader %d", id));
ConfigurationLoader<RegattaConfiguration> globalConfiguration = PreferencesRegattaConfigurationLoader
.loadFromPreferences(preferences);
ConfigurationLoader<RegattaConfiguration> globalConfiguration = PreferencesRegattaConfigurationLoader.loadFromPreferences(preferences);
DataParser<Collection<ManagedRace>> parser = new ManagedRacesDataParser(preferences.getAuthor(),
globalConfiguration, RaceGroupDeserializer.create(domainFactory,
RegattaConfigurationJsonDeserializer.create()));
DataParser<Collection<ManagedRace>> parser = new ManagedRacesDataParser(preferences
.getAuthor(), globalConfiguration, RaceGroupDeserializer.create(domainFactory, RegattaConfigurationJsonDeserializer.create()));
DataHandler<Collection<ManagedRace>> handler = new ManagedRacesDataHandler(OnlineDataManager.this);
List<Util.Pair<String, Object>> params = new ArrayList<>();
params.add(new Util.Pair<String, Object>(RaceLogServletConstants.PARAM_COURSE_AREA_FILTER, courseAreaId.toString()));
params.add(new Util.Pair<String, Object>(RaceLogServletConstants.PARAMS_CLIENT_UUID, MessageSendingService.uuid));
URL url = UrlHelper.generateUrl(preferences.getServerBaseURL(), "/sailingserver/rc/racegroups", params);
return new OnlineDataLoader<Collection<ManagedRace>>(context, url, parser, handler);
return new OnlineDataLoader<>(context, url, parser, handler);
}
}, getContext());
}
@@ -190,7 +191,7 @@ public class OnlineDataManager extends DataManager {
@Override
public LoaderCallbacks<DataLoaderResult<Collection<Mark>>> createMarksLoader(final ManagedRace managedRace,
LoadClient<Collection<Mark>> callback) {
return new DataLoaderCallbacks<Collection<Mark>>(callback, new LoaderCreator<Collection<Mark>>() {
return new DataLoaderCallbacks<>(callback, new LoaderCreator<Collection<Mark>>() {
@Override
public Loader<DataLoaderResult<Collection<Mark>>> create(int id, Bundle args) throws Exception {
ExLog.i(context, TAG, String.format("Creating marks-OnlineDataLoader %d", id));
@@ -209,7 +210,7 @@ public class OnlineDataManager extends DataManager {
params.add(new Util.Pair<String, Object>(RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME, raceColumnName));
params.add(new Util.Pair<String, Object>(RaceLogServletConstants.PARAMS_RACE_FLEET_NAME, fleetName));
URL url = UrlHelper.generateUrl(preferences.getServerBaseURL(), "/sailingserver/rc/marks", params);
return new OnlineDataLoader<Collection<Mark>>(context, url, parser, handler);
return new OnlineDataLoader<>(context, url, parser, handler);
}
}, getContext());
}
@@ -217,13 +218,11 @@ public class OnlineDataManager extends DataManager {
@Override
public LoaderCallbacks<DataLoaderResult<CourseBase>> createCourseLoader(final ManagedRace managedRace,
LoadClient<CourseBase> callback) {
return new DataLoaderCallbacks<CourseBase>(callback, new LoaderCreator<CourseBase>() {
return new DataLoaderCallbacks<>(callback, new LoaderCreator<CourseBase>() {
@Override
public Loader<DataLoaderResult<CourseBase>> create(int id, Bundle args) throws Exception {
ExLog.i(context, TAG, String.format("Creating Course-OnlineDataLoader %d", id));
JsonDeserializer<CourseBase> courseBaseDeserializer = new CourseBaseDeserializer(
new WaypointDeserializer(new ControlPointDeserializer(new MarkDeserializer(domainFactory),
new GateDeserializer(domainFactory, new MarkDeserializer(domainFactory)))));
JsonDeserializer<CourseBase> courseBaseDeserializer = new CourseBaseDeserializer(new WaypointDeserializer(new ControlPointDeserializer(new MarkDeserializer(domainFactory), new GateDeserializer(domainFactory, new MarkDeserializer(domainFactory)))));
DataParser<CourseBase> parser = new CourseBaseParser(courseBaseDeserializer);
DataHandler<CourseBase> handler = new CourseBaseHandler(OnlineDataManager.this, managedRace);
@@ -239,7 +238,7 @@ public class OnlineDataManager extends DataManager {
params.add(new Util.Pair<String, Object>(RaceLogServletConstants.PARAMS_RACE_FLEET_NAME, fleetName));
URL url = UrlHelper.generateUrl(preferences.getServerBaseURL(), "/sailingserver/rc/currentcourse", params);
return new OnlineDataLoader<CourseBase>(context, url, parser, handler);
return new OnlineDataLoader<>(context, url, parser, handler);
}
}, getContext());
}
@@ -247,17 +246,13 @@ public class OnlineDataManager extends DataManager {
@Override
public LoaderCallbacks<DataLoaderResult<Collection<Competitor>>> createCompetitorsLoader(
final ManagedRace managedRace, LoadClient<Collection<Competitor>> callback) {
return new DataLoaderCallbacks<Collection<Competitor>>(callback, new LoaderCreator<Collection<Competitor>>() {
return new DataLoaderCallbacks<>(callback, new LoaderCreator<Collection<Competitor>>() {
@Override
public Loader<DataLoaderResult<Collection<Competitor>>> create(int id, Bundle args) throws Exception {
ExLog.i(context, TAG, String.format("Creating Competitor-OnlineDataLoader %d", id));
JsonDeserializer<Competitor> competitorDeserializer = new CompetitorJsonDeserializer(
domainFactory.getCompetitorStore(), new TeamJsonDeserializer(new PersonJsonDeserializer(
new NationalityJsonDeserializer(domainFactory))), new BoatJsonDeserializer(
new BoatClassJsonDeserializer(domainFactory)));
JsonDeserializer<Competitor> competitorDeserializer = new CompetitorJsonDeserializer(domainFactory.getCompetitorStore(), new TeamJsonDeserializer(new PersonJsonDeserializer(new NationalityJsonDeserializer(domainFactory))), new BoatJsonDeserializer(new BoatClassJsonDeserializer(domainFactory)));
DataParser<Collection<Competitor>> parser = new CompetitorsDataParser(competitorDeserializer);
DataHandler<Collection<Competitor>> handler = new CompetitorsDataHandler(OnlineDataManager.this,
managedRace);
DataHandler<Collection<Competitor>> handler = new CompetitorsDataHandler(OnlineDataManager.this, managedRace);
ManagedRaceIdentifier identifier = managedRace.getIdentifier();
@@ -270,7 +265,7 @@ public class OnlineDataManager extends DataManager {
params.add(new Util.Pair<String, Object>(RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME, raceColumnName));
params.add(new Util.Pair<String, Object>(RaceLogServletConstants.PARAMS_RACE_FLEET_NAME, fleetName));
URL url = UrlHelper.generateUrl(preferences.getServerBaseURL(), "/sailingserver/rc/competitors", params);
return new OnlineDataLoader<Collection<Competitor>>(context, url, parser, handler);
return new OnlineDataLoader<>(context, url, parser, handler);
}
}, getContext());
}
@@ -278,19 +273,17 @@ public class OnlineDataManager extends DataManager {
@Override
public LoaderCallbacks<DataLoaderResult<DeviceConfiguration>> createConfigurationLoader(
final DeviceConfigurationIdentifier identifier, LoadClient<DeviceConfiguration> callback) {
return new DataLoaderCallbacks<DeviceConfiguration>(callback, new LoaderCreator<DeviceConfiguration>() {
return new DataLoaderCallbacks<>(callback, new LoaderCreator<DeviceConfiguration>() {
@Override
public Loader<DataLoaderResult<DeviceConfiguration>> create(int id, Bundle args) throws Exception {
ExLog.i(context, TAG, String.format("Creating Configuration-OnlineDataLoader %d", id));
DataHandler<DeviceConfiguration> handler = new NullDataHandler<DeviceConfiguration>();
DataParser<DeviceConfiguration> parser = new DeviceConfigurationParser(
DeviceConfigurationJsonDeserializer.create());
DataParser<DeviceConfiguration> parser = new DeviceConfigurationParser(DeviceConfigurationJsonDeserializer.create());
String encodedIdentifier = identifier.getClientIdentifier();
List<Util.Pair<String, Object>> params = new ArrayList<>();
params.add(new Util.Pair<String, Object>("client", encodedIdentifier));
URL url = UrlHelper.generateUrl(preferences.getServerBaseURL(), "/sailingserver/rc/configuration", params);
return new OnlineDataLoader<DeviceConfiguration>(context,
url, parser, handler);
return new OnlineDataLoader<>(context, url, parser, handler);
}
}, getContext());
}
@@ -326,5 +319,25 @@ public class OnlineDataManager extends DataManager {
return url;
}
@Override
public LoaderCallbacks<DataLoaderResult<RaceColumnFactorImpl>> createRaceColumnFactorLoader(LoadClient<RaceColumnFactorImpl> callback) {
return new DataLoaderCallbacks<>(callback, new LoaderCreator<RaceColumnFactorImpl>() {
@Override
public Loader<DataLoaderResult<RaceColumnFactorImpl>> create(int id, Bundle args) throws Exception {
if (args == null || args.getString(LEADERBOARD) == null) {
throw new IllegalArgumentException("You need an leaderboard as bundle arg (" + LEADERBOARD + ").");
}
ExLog.i(context, TAG, String.format("Creating RaceColumnFactorLoader %d", id));
DataHandler<RaceColumnFactorImpl> handler = new NullDataHandler<>();
DataParser<RaceColumnFactorImpl> parser = new RaceColumnsParser(new RaceColumnFactorJsonDeserializer());
List<Util.Pair<String, Object>> params = new ArrayList<>();
if (args.getString(RACE_COLUMN) != null) {
params.add(new Util.Pair<String, Object>(RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME, args.getString(RACE_COLUMN)));
}
URL url = UrlHelper.generateUrl(preferences.getServerBaseURL(), "/sailingserver/api/v1/leaderboards/" + args.getString(LEADERBOARD) + "/racecolumnfactors", params);
return new OnlineDataLoader<>(context, url, parser, handler);
}
}, getContext());
}
}
@@ -3,9 +3,6 @@ package com.sap.sailing.racecommittee.app.data;
import java.io.Serializable;
import java.util.Collection;
import android.app.LoaderManager;
import android.app.LoaderManager.LoaderCallbacks;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sailing.domain.base.CourseArea;
import com.sap.sailing.domain.base.CourseBase;
@@ -13,12 +10,16 @@ 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;
/**
* <p>
* Interface for everything read related when working with data.
@@ -42,7 +43,7 @@ public interface ReadonlyDataManager {
*
* @return the {@link DataStore}.
*/
public DataStore getDataStore();
DataStore getDataStore();
/**
* Creates a new {@link LoaderCallbacks} object for loading {@link EventBase}s.
@@ -53,8 +54,7 @@ public interface ReadonlyDataManager {
* {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or
* {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}.
*/
public LoaderCallbacks<DataLoaderResult<Collection<EventBase>>> createEventsLoader(
LoadClient<Collection<EventBase>> callback);
LoaderCallbacks<DataLoaderResult<Collection<EventBase>>> createEventsLoader(LoadClient<Collection<EventBase>> callback);
/**
* Creates a new {@link LoaderCallbacks} object for loading {@link CourseArea}s.
@@ -65,24 +65,20 @@ public interface ReadonlyDataManager {
* {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or
* {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}.
*/
public LoaderCallbacks<DataLoaderResult<Collection<CourseArea>>> createCourseAreasLoader(
Serializable parentEventId, LoadClient<Collection<CourseArea>> callback);
LoaderCallbacks<DataLoaderResult<Collection<CourseArea>>> createCourseAreasLoader(Serializable parentEventId,
LoadClient<Collection<CourseArea>> callback);
LoaderCallbacks<DataLoaderResult<Collection<CourseArea>>> createCourseAreasLoader(EventBase parentEvent,
LoadClient<Collection<CourseArea>> callback);
public LoaderCallbacks<DataLoaderResult<Collection<CourseArea>>> createCourseAreasLoader(
EventBase parentEvent, LoadClient<Collection<CourseArea>> callback);
/**
* Creates a new {@link LoaderCallbacks} object for loading racing referee positions.
*
* @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)}.
*/
public LoaderCallbacks<DataLoaderResult<Collection<CoursePosition>>> createPositionLoader(
PositionListFragment positionListFragment);
LoaderCallbacks<DataLoaderResult<Collection<CoursePosition>>> createPositionLoader(PositionListFragment positionListFragment);
/**
* Creates a new {@link LoaderCallbacks} object for loading {@link ManagedRace}s of a specific {@link CourseArea}.
@@ -95,8 +91,8 @@ public interface ReadonlyDataManager {
* {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or
* {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}.
*/
public LoaderCallbacks<DataLoaderResult<Collection<ManagedRace>>> createRacesLoader(Serializable courseAreaId,
LoadClient<Collection<ManagedRace>> callback);
LoaderCallbacks<DataLoaderResult<Collection<ManagedRace>>> createRacesLoader(Serializable courseAreaId,
LoadClient<Collection<ManagedRace>> callback);
/**
* Creates a new {@link LoaderCallbacks} object for loading a race's {@link Mark}s.
@@ -109,8 +105,7 @@ public interface ReadonlyDataManager {
* {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or
* {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}.
*/
public LoaderCallbacks<DataLoaderResult<Collection<Mark>>> createMarksLoader(ManagedRace managedRace,
LoadClient<Collection<Mark>> callback);
LoaderCallbacks<DataLoaderResult<Collection<Mark>>> createMarksLoader(ManagedRace managedRace, LoadClient<Collection<Mark>> callback);
/**
* Creates a new {@link LoaderCallbacks} object for loading a race's {@link CourseBase}.
@@ -123,8 +118,7 @@ public interface ReadonlyDataManager {
* {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or
* {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}.
*/
public LoaderCallbacks<DataLoaderResult<CourseBase>> createCourseLoader(ManagedRace managedRace,
LoadClient<CourseBase> callback);
LoaderCallbacks<DataLoaderResult<CourseBase>> createCourseLoader(ManagedRace managedRace, LoadClient<CourseBase> callback);
/**
* Creates a new {@link LoaderCallbacks} object for loading {@link Competitor}s.
@@ -135,8 +129,8 @@ public interface ReadonlyDataManager {
* {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or
* {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}.
*/
public LoaderCallbacks<DataLoaderResult<Collection<Competitor>>> createCompetitorsLoader(ManagedRace managedRace,
LoadClient<Collection<Competitor>> callback);
LoaderCallbacks<DataLoaderResult<Collection<Competitor>>> createCompetitorsLoader(ManagedRace managedRace,
LoadClient<Collection<Competitor>> callback);
/**
* Creates a new {@link LoaderCallbacks} object for loading a client's configuration.
@@ -147,8 +141,22 @@ public interface ReadonlyDataManager {
* {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderCallbacks)} or
* {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderCallbacks)}.
*/
public LoaderCallbacks<DataLoaderResult<DeviceConfiguration>> createConfigurationLoader(DeviceConfigurationIdentifier identifier,
LoadClient<DeviceConfiguration> callback);
LoaderCallbacks<DataLoaderResult<DeviceConfiguration>> createConfigurationLoader(DeviceConfigurationIdentifier identifier,
LoadClient<DeviceConfiguration> callback);
public String getMapUrl(String baseUrl, ManagedRace race, String eventId, boolean showWindCharts, boolean showStreamlets, boolean showSimulation, boolean showMapControls);
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<DataLoaderResult<RaceColumnFactorImpl>> createRaceColumnFactorLoader(LoadClient<RaceColumnFactorImpl> callback);
}
@@ -26,7 +26,7 @@ public class CompetitorsDataHandler extends DataHandler<Collection<Competitor>>
}
@Override
public void onResult(Collection<Competitor> data) {
public void onResult(Collection<Competitor> data, boolean isCached) {
race.setCompetitors(data);
}
@@ -24,7 +24,7 @@ public class CourseBaseHandler extends DataHandler<CourseBase> {
}
@Override
public void onResult(CourseBase data) {
public void onResult(CourseBase data, boolean isCached) {
race.setCourseOnServer(data);
}
@@ -9,7 +9,7 @@ public abstract class DataHandler<T> {
this.manager = manager;
}
public abstract void onResult(T data);
public abstract void onResult(T data, boolean isCached);
public boolean hasCachedResults() {
return false;
@@ -12,7 +12,7 @@ public class EventsDataHandler extends DataHandler<Collection<EventBase>> {
}
@Override
public void onResult(Collection<EventBase> data) {
public void onResult(Collection<EventBase> data, boolean isCached) {
manager.addEvents(data);
}
@@ -26,9 +26,20 @@ public class ManagedRacesDataHandler extends DataHandler<Collection<ManagedRace>
}
@Override
public void onResult(Collection<ManagedRace> data) {
manager.addRaces(data);
calcRaceState(data);
public void onResult(Collection<ManagedRace> data, boolean isCached) {
if (!isCached) {
Set<DeleteFromDataStore> deleteList = new HashSet<>();
for (ManagedRace race : manager.getDataStore().getRaces()) {
if (!data.contains(race)) {
deleteList.add(new DeleteFromDataStore(manager, race));
}
}
for (DeleteFromDataStore action : deleteList) {
action.run();
}
manager.addRaces(data);
calcRaceState(data);
}
}
private void calcRaceState(Collection<ManagedRace> data) {
@@ -54,4 +65,20 @@ public class ManagedRacesDataHandler extends DataHandler<Collection<ManagedRace>
raceStatesWithUnresolvedStartTimes.removeAll(resolved);
} while (oldNumberOfRaceStatesWithUnresolvedStartTimes != raceStatesWithUnresolvedStartTimes.size());
}
private static class DeleteFromDataStore implements Runnable {
private final OnlineDataManager mManager;
private final ManagedRace mRace;
public DeleteFromDataStore(OnlineDataManager manager, ManagedRace race) {
mManager = manager;
mRace = race;
}
@Override
public void run() {
mManager.getDataStore().removeRace(mRace);
}
}
}
@@ -22,7 +22,7 @@ public class MarksDataHandler extends DataHandler<Collection<Mark>> {
}
@Override
public void onResult(Collection<Mark> data) {
public void onResult(Collection<Mark> data, boolean isCached) {
manager.addMarks(data);
}
@@ -13,7 +13,7 @@ public class NullDataHandler<T> extends DataHandler<T> {
}
@Override
public void onResult(T data) {
public void onResult(T data, boolean isCached) {
// no operation
}
@@ -1,5 +1,10 @@
package com.sap.sailing.racecommittee.app.data.loaders;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import android.content.AsyncTaskLoader;
import android.content.Context;
import android.content.Loader;
@@ -10,11 +15,6 @@ import com.sap.sailing.android.shared.logging.ExLog;
import com.sap.sailing.racecommittee.app.data.handlers.DataHandler;
import com.sap.sailing.racecommittee.app.data.parsers.DataParser;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
/**
* <p>
* A {@link Loader} that loads data by accessing a remote resource.
@@ -27,7 +27,7 @@ import java.net.URL;
* <p/>
* <p>
* The data returned by the remote resource is parsed by the given {@link DataParser} and may be cached through your
* implementation of {@link DataHandler#onResult(Object)}.
* implementation of {@link DataHandler#onResult(Object, boolean)}.
* </p>
*
* @param <T> result type.
@@ -78,7 +78,7 @@ public class OnlineDataLoader<T> extends AsyncTaskLoader<DataLoaderResult<T>> {
@Override
public void deliverResult(DataLoaderResult<T> result) {
if (result.isSuccessful()) {
dataHandler.onResult(result.getResult());
dataHandler.onResult(result.getResult(), result.isResultCached());
}
super.deliverResult(result);
}
@@ -64,7 +64,7 @@ public class ManagedRacesDataParser implements DataParser<Collection<ManagedRace
for (RaceRow raceRow : series.getRaceRows()) {
Fleet fleet = raceRow.getFleet();
for (RaceCell cell : raceRow.getCells()) {
ManagedRace race = createManagedRace(raceGroup, series, fleet, cell.getName(), cell.getRaceLog());
ManagedRace race = createManagedRace(raceGroup, series, fleet, cell.getName(), cell.getRaceLog(), cell.getFactor(), cell.getExplicitFactor());
target.add(race);
}
}
@@ -72,7 +72,7 @@ public class ManagedRacesDataParser implements DataParser<Collection<ManagedRace
}
private ManagedRace createManagedRace(RaceGroup raceGroup, SeriesBase series, Fleet fleet, String name,
RaceLog raceLog) {
RaceLog raceLog, double factor, Double explicitFactor) {
ConfigurationLoader<RegattaConfiguration> configurationLoader = globalConfigurationLoader;
RegattaConfiguration localConfiguration = raceGroup.getRegattaConfiguration();
if (localConfiguration != null) {
@@ -80,7 +80,7 @@ public class ManagedRacesDataParser implements DataParser<Collection<ManagedRace
}
FleetIdentifier fleetIdentifier = new FleetIdentifierImpl(fleet, series, raceGroup);
ManagedRaceIdentifier identifier = new ManagedRaceIdentifierImpl(name, fleetIdentifier);
return new ManagedRaceImpl(identifier, new ManagedRaceCalculator(raceLog, author, configurationLoader));
return new ManagedRaceImpl(identifier, new ManagedRaceCalculator(raceLog, author, configurationLoader), factor, explicitFactor);
}
}
@@ -0,0 +1,26 @@
package com.sap.sailing.racecommittee.app.data.parsers;
import java.io.Reader;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import com.sap.sailing.domain.base.impl.RaceColumnFactorImpl;
import com.sap.sailing.server.gateway.deserialization.impl.Helpers;
import com.sap.sailing.server.gateway.deserialization.impl.RaceColumnFactorJsonDeserializer;
public class RaceColumnsParser implements DataParser<RaceColumnFactorImpl> {
private RaceColumnFactorJsonDeserializer deserializer;
public RaceColumnsParser(RaceColumnFactorJsonDeserializer deserializer) {
this.deserializer = deserializer;
}
@Override
public RaceColumnFactorImpl parse(Reader reader) throws Exception {
Object parsedResult = JSONValue.parseWithException(reader);
JSONObject jsonObject = Helpers.toJSONObjectSafe(parsedResult);
return deserializer.deserialize(jsonObject);
}
}
@@ -104,4 +104,19 @@ public interface ManagedRace extends ManagedRaceIdentifier, Named, WithID {
* @return result object
*/
Result setFinishingTime(TimePoint finishingTime);
/**
* @return
*/
double getFactor();
/**
* @return factor
*/
Double getExplicitFactor();
/**
* @param factor
*/
void setExplicitFactor(Double factor);
}
@@ -17,20 +17,17 @@ public class PreferencesDeviceConfigurationLoader implements ConfigurationLoader
private final DeviceConfigurationImpl configuration;
private final AppPreferences preferences;
private final ConfigurationLoader<RegattaConfiguration> regattaConfigurationLoader;
public static PreferencesDeviceConfigurationLoader wrap(DeviceConfiguration configuration, AppPreferences preferences) {
RegattaConfiguration regattaConfiguration = configuration.getRegattaConfiguration();
if (regattaConfiguration == null) {
regattaConfiguration = new RegattaConfigurationImpl();
}
return new PreferencesDeviceConfigurationLoader(
configuration,
new PreferencesRegattaConfigurationLoader(regattaConfiguration, preferences),
preferences);
return new PreferencesDeviceConfigurationLoader(configuration, new PreferencesRegattaConfigurationLoader(regattaConfiguration, preferences), preferences);
}
private PreferencesDeviceConfigurationLoader(DeviceConfiguration configuration, PreferencesRegattaConfigurationLoader regattaLoader,
AppPreferences preferences) {
AppPreferences preferences) {
if (!(configuration instanceof DeviceConfigurationImpl)) {
throw new IllegalArgumentException("configuration");
}
@@ -44,7 +41,7 @@ public class PreferencesDeviceConfigurationLoader implements ConfigurationLoader
if (regattaConfigurationLoader != null) {
configuration.setRegattaConfiguration(regattaConfigurationLoader.load());
}
configuration.setAllowedCourseAreaNames(preferences.getManagedCourseAreaNames());
configuration.setResultsMailRecipient(preferences.getMailRecipient());
configuration.setByNameDesignerCourseNames(preferences.getByNameCourseDesignerCourseNames());
@@ -55,12 +52,12 @@ public class PreferencesDeviceConfigurationLoader implements ConfigurationLoader
public void store() {
Context context = preferences.getContext();
ExLog.i(context, TAG, "Storing new device configuration.");
if (regattaConfigurationLoader != null) {
regattaConfigurationLoader.store();
logApply(context, "regatta configuration", "[object]");
}
if (configuration.getAllowedCourseAreaNames() != null) {
preferences.setManagedCourseAreaNames(configuration.getAllowedCourseAreaNames());
logApply(context, "course areas", configuration.getAllowedCourseAreaNames());
@@ -73,10 +70,11 @@ public class PreferencesDeviceConfigurationLoader implements ConfigurationLoader
preferences.setByNameCourseDesignerCourseNames(configuration.getByNameCourseDesignerCourseNames());
logApply(context, "by name course designer course names", configuration.getByNameCourseDesignerCourseNames());
}
}
private static void logApply(Context context, String configurationName, Object value) {
ExLog.i(context, TAG, String.format("Applied '%s' configuration: %s.", configurationName, value==null?"null":value.toString()));
preferences.setNeedConfigRefresh(false);
}
private static void logApply(Context context, String configurationName, Object value) {
ExLog.i(context, TAG, String.format("Applied '%s' configuration: %s.", configurationName, value == null ? "null" : value.toString()));
}
}
@@ -31,18 +31,24 @@ public class ManagedRaceImpl implements ManagedRace {
private List<MapMarker> mapMarkers;
private CourseBase courseOnServer;
private ManagedRaceCalculator calculator;
private double factor;
private Double explicitFactor;
public ManagedRaceImpl(ManagedRaceIdentifier identifier, RaceState state) {
this.state = state;
private ManagedRaceImpl(ManagedRaceIdentifier identifier, double factor, Double explicitFactor) {
this.identifier = identifier;
this.competitors = new ArrayList<>();
this.courseOnServer = null;
this.factor = factor;
this.explicitFactor = explicitFactor;
}
public ManagedRaceImpl(ManagedRaceIdentifier identifier, ManagedRaceCalculator calculator) {
this.identifier = identifier;
this.competitors = new ArrayList<>();
this.courseOnServer = null;
public ManagedRaceImpl(ManagedRaceIdentifier identifier, RaceState state) {
this(identifier, 0, null);
this.state = state;
}
public ManagedRaceImpl(ManagedRaceIdentifier identifier, ManagedRaceCalculator calculator, double factor, Double explicitFactor) {
this(identifier, factor, explicitFactor);
this.calculator = calculator;
}
@@ -177,6 +183,20 @@ public class ManagedRaceImpl implements ManagedRace {
return result;
}
public double getFactor() {
return factor;
}
@Override
public Double getExplicitFactor() {
return explicitFactor;
}
@Override
public void setExplicitFactor(Double factor) {
this.explicitFactor = factor;
}
@Override
public String toString() {
return "ManagedRaceImpl [identifier=" + identifier + "]";
@@ -3,9 +3,11 @@ package com.sap.sailing.racecommittee.app.services;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import android.annotation.TargetApi;
@@ -19,6 +21,8 @@ import android.graphics.BitmapFactory;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat;
import android.util.Pair;
@@ -74,7 +78,7 @@ public class RaceStateService extends Service {
private Map<ManagedRace, RaceLogEventVisitor> registeredLogListeners;
private Map<ManagedRace, RaceStateEventScheduler> registeredStateEventSchedulers;
private Map<Serializable, List<Pair<PendingIntent, RaceStateEvents>>> managedIntents;
private Map<String, List<Pair<PendingIntent, RaceStateEvents>>> managedIntents;
private NotificationManager notificationManager;
private NotificationCompat.Builder notificationBuilder;
@@ -104,7 +108,7 @@ public class RaceStateService extends Service {
launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, launcherIntent, 0);
notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_directions_boat)
.setSmallIcon(R.drawable.ic_boat_white_24dp)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
.setContentTitle(getText(R.string.service_info))
.setContentText(getString(R.string.service_text_no_races))
@@ -146,10 +150,12 @@ public class RaceStateService extends Service {
for (Entry<ManagedRace, RaceLogEventVisitor> entry : registeredLogListeners.entrySet()) {
entry.getKey().getState().getRaceLog().removeListener(entry.getValue());
}
registeredLogListeners.clear();
for (Entry<ManagedRace, RaceStateEventScheduler> entry : registeredStateEventSchedulers.entrySet()) {
entry.getKey().getState().setStateEventScheduler(null);
}
registeredStateEventSchedulers.clear();
for (List<Pair<PendingIntent, RaceStateEvents>> intents : managedIntents.values()) {
for (Pair<PendingIntent,RaceStateEvents> intentPair : intents) {
@@ -161,12 +167,48 @@ public class RaceStateService extends Service {
ExLog.i(this, TAG, "All races unregistered.");
}
private void unregisterRace(ManagedRace race) {
poller.unregister(race);
race.getState().getRaceLog().removeAllListeners();
registeredLogListeners.remove(race);
race.getState().setStateEventScheduler(null);
registeredStateEventSchedulers.remove(race);
List<Pair<PendingIntent, RaceStateEvents>> intents = managedIntents.get(race.getId());
for (Pair<PendingIntent, RaceStateEvents> intentPair : intents) {
alarmManager.cancel(intentPair.first);
}
managedIntents.remove(race.getId());
ExLog.i(this, TAG, "Race " + race.getId() + " unregistered");
}
private void unregisterRace(@Nullable String raceId) {
ManagedRace raceToUnregister = null;
for (ManagedRace race: registeredStateEventSchedulers.keySet()) {
if (race.getId().equals(raceId)) {
raceToUnregister = race;
}
}
if (raceToUnregister != null) {
unregisterRace(raceToUnregister);
}
}
private void handleStartCommand(Intent intent) {
String action = intent.getAction();
ExLog.i(this, TAG, String.format("Command action '%s' received.", action));
if (AppConstants.INTENT_ACTION_CLEAR_RACES.equals(action)) {
handleClearRaces(intent);
handleClearRaces();
return;
}
if (AppConstants.INTENT_ACTION_CLEANUP_RACES.equals(action)) {
handleCleanupRaces();
return;
}
@@ -175,6 +217,11 @@ public class RaceStateService extends Service {
return;
}
if (AppConstants.INTENT_ACTION_UNREGISTER_RACE.equals(action)) {
handleUnregisterRace(intent);
return;
}
if (!serviceId.equals(intent.getSerializableExtra(EXTRAS_SERVICE_ID))) {
ExLog.w(this, TAG, "Received event for different service version.");
return;
@@ -196,7 +243,7 @@ public class RaceStateService extends Service {
}
}
private void handleClearRaces(Intent intent) {
private void handleClearRaces() {
unregisterAllRaces();
DataStore dataStore = dataManager.getDataStore();
dataStore.getRaces().clear();
@@ -206,6 +253,46 @@ public class RaceStateService extends Service {
stopForeground(true);
}
private class RemoveRaceAction implements Runnable {
private final ManagedRace managedRace;
public RemoveRaceAction(@NonNull ManagedRace race) {
managedRace = race;
}
@Override
public void run() {
unregisterRace(managedRace);
}
}
private void handleCleanupRaces() {
Set<RemoveRaceAction> actions = new HashSet<>();
for (String raceId : managedIntents.keySet()) {
if (!inDataStore(raceId)) {
for (ManagedRace race : registeredLogListeners.keySet()) {
if (race.getId().equals(raceId)) {
actions.add(new RemoveRaceAction(race));
}
}
}
}
for (RemoveRaceAction action : actions) {
action.run();
}
updateNotification();
}
private boolean inDataStore(String raceId) {
for (ManagedRace race : dataManager.getDataStore().getRaces()) {
if (race.getId().equals(raceId)) {
return true;
}
}
return false;
}
private void handleRegisterRace(Intent intent) {
ManagedRace race = getRaceFromIntent(intent);
if (race == null) {
@@ -214,6 +301,21 @@ public class RaceStateService extends Service {
}
registerRace(race);
updateNotification();
}
private void handleUnregisterRace(Intent intent) {
ManagedRace race = getRaceFromIntent(intent);
if (race == null) {
ExLog.w(this, TAG, "Intent did not carry valid race information");
return;
}
unregisterRace(race);
updateNotification();
}
private void updateNotification() {
int numRaces = managedIntents.keySet().size();
notificationManager.notify(NOTIFICATION_ID, notificationBuilder
.setContentText(getString(R.string.service_text_num_races, numRaces))
@@ -249,12 +351,14 @@ public class RaceStateService extends Service {
// ... and register for polling!
poller.register(race);
this.registeredLogListeners.put(race, logListener);
this.registeredStateEventSchedulers.put(race, stateEventScheduler);
registeredLogListeners.put(race, logListener);
registeredStateEventSchedulers.put(race, stateEventScheduler);
ExLog.i(this, TAG, "Race " + race.getId() + " registered.");
} else {
ExLog.w(this, TAG, "Race " + race.getId() + " was already registered. Ignoring.");
ExLog.w(this, TAG, "Race " + race.getId() + " was already registered. Cleaning up.");
unregisterRace(race.getId());
registerRace(race);
}
}
@@ -49,7 +49,7 @@ public class RaceLogPoller implements PollingActiveChangedListener {
// We want to use the main (UI) loop
this.pollingHandler = new Handler(Looper.getMainLooper());
this.pollingWorker = new PollingWorker(this, context);
this.races = new HashMap<ManagedRace, URL>();
this.races = new HashMap<>();
this.appPreferences = AppPreferences.on(context);
this.appPreferences.registerPollingActiveChangedListener(this);
this.hasRacesToPoll = false;
@@ -70,6 +70,10 @@ public class RaceLogPoller implements PollingActiveChangedListener {
}
}
public void unregister(ManagedRace race) {
races.remove(race);
}
private URL createURL(ManagedRace race) throws MalformedURLException, UnsupportedEncodingException {
return new URL(MessageSendingService.getRaceLogEventSendAndReceiveUrl(context, race.getRaceGroup().getName(),
race.getName(), race.getFleet().getName()));
Loaded 100 of 315 files, more files were not shown because too many files have changed in this diff. Show more