mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-31 16:20:45 +00:00
RCApp: Race Summary duration
This commit is contained in:
1 parent
147b94ff04
commit
030f130a8d
12 files changed
+148
-41
No files matched your search
@@ -32,7 +32,7 @@
|
||||
android:layout_marginRight="@dimen/default_margin"
|
||||
android:layout_toLeftOf="@id/more_data"
|
||||
android:text="@string/set_signal"
|
||||
android:visibility="visible"
|
||||
android:visibility="gone"
|
||||
android:layout_alignParentRight="true"
|
||||
style="?attr/buttonSolidNormal" />
|
||||
|
||||
|
||||
@@ -82,7 +82,8 @@
|
||||
android:drawableStart="?access_time_36dp"
|
||||
tools:text="@string/time"
|
||||
android:textSize="@dimen/textSize_40"
|
||||
android:gravity="center" />
|
||||
android:gravity="center"
|
||||
android:visibility="invisible" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/record_button">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/voice_header"
|
||||
@@ -51,7 +52,8 @@
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/photo_button">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/photo_header"
|
||||
@@ -95,7 +97,8 @@
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/list_button">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/list_header"
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
android:padding="@dimen/default_padding_half"
|
||||
android:textAppearance="?textNormal"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="@string/protest_time" />
|
||||
android:text="@string/protest_time"
|
||||
android:id="@+id/protest_button" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
@@ -54,7 +55,8 @@
|
||||
android:layout_centerInParent="true"
|
||||
android:text="@string/finished_text_01"
|
||||
android:gravity="center"
|
||||
style="?textSmall" />
|
||||
style="?textSmall"
|
||||
android:id="@+id/publish_advice" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
@@ -63,7 +65,8 @@
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="@dimen/default_margin_twice"
|
||||
android:text="@string/finished_submit"
|
||||
style="?buttonSolidSmall" />
|
||||
style="?buttonSolidSmall"
|
||||
android:id="@+id/submit_button" />
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/thin_line"
|
||||
|
||||
@@ -358,7 +358,7 @@
|
||||
<string name="race_summary_finish_end">End Finish</string>
|
||||
<string name="race_summary_finish_duration">Finish Duration</string>
|
||||
<string name="race_summary_wind_direction">Average Wind Direction</string>
|
||||
<string name="race_summary_wind_direction_value" translatable="false">from %s°</string>
|
||||
<string name="race_summary_wind_direction_value" translatable="false">from %.0f°</string>
|
||||
<string name="race_summary_wind_speed">Average Wind Speed</string>
|
||||
<string name="race_summary_wind_speed_value" translatable="false">%.1f kts</string>
|
||||
<string name="race_summary_individual_recalls">Individual Recalls</string>
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ public abstract class FragmentAttachedDialogFragment extends AttachedDialogFragm
|
||||
return (DialogListenerHost) targetFragment;
|
||||
}
|
||||
throw new IllegalStateException(String.format("Instance of %s must be attached to instances of %s.",
|
||||
FragmentAttachedDialogFragment.class.getName(), DialogListenerHost.class.getName()));
|
||||
targetFragment.getClass().getName(), DialogListenerHost.class.getName()));
|
||||
}
|
||||
|
||||
}
|
||||
+9
@@ -9,6 +9,7 @@ import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.racingprocedure.RacingProcedure;
|
||||
import com.sap.sailing.racecommittee.app.AppConstants;
|
||||
import com.sap.sailing.racecommittee.app.AppPreferences;
|
||||
@@ -99,4 +100,12 @@ public abstract class BasePanelFragment extends RaceFragment {
|
||||
.replace(R.id.race_frame, fragment)
|
||||
.commit();
|
||||
}
|
||||
|
||||
protected class NotYetImplemented implements View.OnClickListener {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(getActivity(), "Function not yet implemented.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
-1
@@ -1,10 +1,11 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.panels;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
import com.sap.sailing.android.shared.util.ViewHolder;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
|
||||
public class FinishedButtonFragment extends BasePanelFragment {
|
||||
@@ -19,6 +20,24 @@ public class FinishedButtonFragment extends BasePanelFragment {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.race_finished_left, container, false);
|
||||
|
||||
RelativeLayout record = ViewHolder.get(layout, R.id.record_button);
|
||||
if (record != null) {
|
||||
// TODO
|
||||
record.setOnClickListener(new NotYetImplemented());
|
||||
}
|
||||
|
||||
RelativeLayout photo = ViewHolder.get(layout, R.id.photo_button);
|
||||
if (photo != null) {
|
||||
// TODO
|
||||
photo.setOnClickListener(new NotYetImplemented());
|
||||
}
|
||||
|
||||
RelativeLayout list = ViewHolder.get(layout, R.id.list_button);
|
||||
if (list != null) {
|
||||
// TODO
|
||||
list.setOnClickListener(new NotYetImplemented());
|
||||
}
|
||||
|
||||
return layout;
|
||||
}
|
||||
}
|
||||
+14
@@ -5,6 +5,8 @@ import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import com.sap.sailing.android.shared.util.ViewHolder;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
|
||||
public class FinishedSubmitFragment extends BasePanelFragment {
|
||||
@@ -19,6 +21,18 @@ public class FinishedSubmitFragment extends BasePanelFragment {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.race_finished_right, container, false);
|
||||
|
||||
Button protest = ViewHolder.get(layout, R.id.protest_button);
|
||||
if (protest != null) {
|
||||
// TODO
|
||||
protest.setOnClickListener(new NotYetImplemented());
|
||||
}
|
||||
|
||||
Button submit = ViewHolder.get(layout, R.id.submit_button);
|
||||
if (submit != null) {
|
||||
// TODO
|
||||
submit.setOnClickListener(new NotYetImplemented());
|
||||
}
|
||||
|
||||
return layout;
|
||||
}
|
||||
}
|
||||
+19
@@ -6,6 +6,8 @@ import android.os.Bundle;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.widget.TextView;
|
||||
import com.sap.sailing.android.shared.logging.ExLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.ReadonlyRaceState;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.impl.BaseRaceStateChangedListener;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.racingprocedure.FlagPoleState;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.racingprocedure.RacingProcedure;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.racingprocedure.ReadonlyRacingProcedure;
|
||||
@@ -27,12 +29,16 @@ import java.util.List;
|
||||
|
||||
public abstract class BaseRaceInfoRaceFragment<ProcedureType extends RacingProcedure> extends RaceFragment {
|
||||
|
||||
private final RaceStateChangedListener raceStateChangedListener;
|
||||
private final ProcedureChangedListener procedureListener;
|
||||
|
||||
protected RaceInfoListener infoListener;
|
||||
private FlagPoleCache flagPoleCache;
|
||||
|
||||
public BaseRaceInfoRaceFragment() {
|
||||
raceStateChangedListener = new RaceStateChangedListener();
|
||||
procedureListener = new ProcedureChangedListener();
|
||||
|
||||
flagPoleCache = null;
|
||||
}
|
||||
|
||||
@@ -61,6 +67,8 @@ public abstract class BaseRaceInfoRaceFragment<ProcedureType extends RacingProce
|
||||
super.onStart();
|
||||
|
||||
setupUi();
|
||||
|
||||
getRaceState().addChangedListener(raceStateChangedListener);
|
||||
getRacingProcedure().addChangedListener(procedureListener);
|
||||
}
|
||||
|
||||
@@ -68,6 +76,7 @@ public abstract class BaseRaceInfoRaceFragment<ProcedureType extends RacingProce
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
getRaceState().removeChangedListener(raceStateChangedListener);
|
||||
getRacingProcedure().removeChangedListener(procedureListener);
|
||||
}
|
||||
|
||||
@@ -165,6 +174,16 @@ public abstract class BaseRaceInfoRaceFragment<ProcedureType extends RacingProce
|
||||
}
|
||||
}
|
||||
|
||||
private class RaceStateChangedListener extends BaseRaceStateChangedListener {
|
||||
|
||||
@Override
|
||||
public void onFinishedTimeChanged(ReadonlyRaceState state) {
|
||||
super.onFinishedTimeChanged(state);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class ProcedureChangedListener extends BaseRacingProcedureChangedListener {
|
||||
@Override
|
||||
public void onActiveFlagsChanged(ReadonlyRacingProcedure racingProcedure) {
|
||||
|
||||
+25
-6
@@ -20,6 +20,7 @@ import com.sap.sailing.racecommittee.app.ui.adapters.MoreFlagsAdapter.MoreFlagIt
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class MoreFlagsFragment extends ScheduleFragment implements MoreFlagItemClick {
|
||||
@@ -86,7 +87,9 @@ public class MoreFlagsFragment extends ScheduleFragment implements MoreFlagItemC
|
||||
|
||||
public static final String STARTMODE = "startMode";
|
||||
|
||||
private SimpleDateFormat mDateFormat;
|
||||
private TimePicker mTimePicker;
|
||||
private TextView mCurrentTime;
|
||||
|
||||
public FinishingTimeFragment() {
|
||||
|
||||
@@ -105,6 +108,8 @@ public class MoreFlagsFragment extends ScheduleFragment implements MoreFlagItemC
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.race_finish_config, container, false);
|
||||
|
||||
mDateFormat = new SimpleDateFormat("HH:mm:ss", getResources().getConfiguration().locale);
|
||||
|
||||
View header = ViewHolder.get(layout, R.id.header_text);
|
||||
if (header != null) {
|
||||
// header.setOnClickListener(this);
|
||||
@@ -115,14 +120,16 @@ public class MoreFlagsFragment extends ScheduleFragment implements MoreFlagItemC
|
||||
mTimePicker.setIs24HourView(true);
|
||||
}
|
||||
|
||||
View currentTime = ViewHolder.get(layout, R.id.finish_current);
|
||||
if (currentTime != null) {
|
||||
currentTime.setOnClickListener(this);
|
||||
mCurrentTime = ViewHolder.get(layout, R.id.current_time);
|
||||
|
||||
View finishCurrent = ViewHolder.get(layout, R.id.finish_current);
|
||||
if (finishCurrent != null) {
|
||||
finishCurrent.setOnClickListener(this);
|
||||
}
|
||||
|
||||
View customTime = ViewHolder.get(layout, R.id.finish_custom);
|
||||
if (customTime != null) {
|
||||
customTime.setOnClickListener(this);
|
||||
View finishCustom = ViewHolder.get(layout, R.id.finish_custom);
|
||||
if (finishCustom != null) {
|
||||
finishCustom.setOnClickListener(this);
|
||||
}
|
||||
|
||||
if (getArguments().getInt(STARTMODE, 0) != 0) {
|
||||
@@ -178,6 +185,18 @@ public class MoreFlagsFragment extends ScheduleFragment implements MoreFlagItemC
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyTick() {
|
||||
super.notifyTick();
|
||||
|
||||
TimePoint now = MillisecondsTimePoint.now();
|
||||
|
||||
if (mCurrentTime != null) {
|
||||
mCurrentTime.setText(mDateFormat.format(now.asMillis()));
|
||||
mCurrentTime.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void setFinishTime(boolean current) {
|
||||
TimePoint finishingTime;
|
||||
if (current) {
|
||||
|
||||
+44
-24
@@ -23,6 +23,7 @@ import com.sap.sailing.racecommittee.app.R;
|
||||
import com.sap.sailing.racecommittee.app.domain.ManagedRace;
|
||||
import com.sap.sailing.racecommittee.app.domain.impl.BoatClassSeriesFleet;
|
||||
import com.sap.sailing.racecommittee.app.ui.activities.ResultsCapturingActivity;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.panels.BasePanelFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.panels.FinishedButtonFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.panels.FinishedSubmitFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.BaseRaceInfoRaceFragment;
|
||||
@@ -32,9 +33,12 @@ import com.sap.sse.common.TimePoint;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public abstract class BaseFinishedRaceFragment<ProcedureType extends RacingProcedure> extends BaseRaceInfoRaceFragment<ProcedureType> {
|
||||
|
||||
private Calendar mCalendar;
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.race_finished, container, false);
|
||||
@@ -52,7 +56,21 @@ public abstract class BaseFinishedRaceFragment<ProcedureType extends RacingProce
|
||||
replaceFragment(FinishedButtonFragment.newInstance(getArguments()), R.id.finished_panel_left);
|
||||
replaceFragment(FinishedSubmitFragment.newInstance(getArguments()), R.id.finished_panel_right);
|
||||
|
||||
ImageView button = ViewHolder.get(getView(), R.id.edit_summary);
|
||||
mCalendar = Calendar.getInstance();
|
||||
|
||||
Calendar start = (Calendar) mCalendar.clone();
|
||||
start.setTime(getRaceState().getStartTime().asDate());
|
||||
Calendar startTime = floorTime(start);
|
||||
|
||||
Calendar finishing = (Calendar) mCalendar.clone();
|
||||
finishing.setTime(getRaceState().getFinishingTime().asDate());
|
||||
Calendar finishingTime = floorTime(finishing);
|
||||
|
||||
Calendar finished = (Calendar) mCalendar.clone();
|
||||
finished.setTime(getRaceState().getFinishedTime().asDate());
|
||||
Calendar finishedTime = floorTime(finished);
|
||||
|
||||
final ImageView button = ViewHolder.get(getView(), R.id.edit_summary);
|
||||
if (button != null) {
|
||||
button.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
@@ -64,32 +82,32 @@ public abstract class BaseFinishedRaceFragment<ProcedureType extends RacingProce
|
||||
|
||||
TextView start_time = ViewHolder.get(getView(), R.id.race_start_time);
|
||||
if (start_time != null) {
|
||||
start_time.setText(dateFormat.format(getRaceState().getStartTime().asDate()));
|
||||
start_time.setText(dateFormat.format(startTime.getTime()));
|
||||
}
|
||||
|
||||
TextView finish_start_time = ViewHolder.get(getView(), R.id.race_finish_begin_time);
|
||||
if (finish_start_time != null) {
|
||||
finish_start_time.setText(dateFormat.format(getRaceState().getFinishingTime().asDate()));
|
||||
finish_start_time.setText(dateFormat.format(finishingTime.getTime()));
|
||||
}
|
||||
|
||||
TextView finish_start_duration = ViewHolder.get(getView(), R.id.race_finish_begin_duration);
|
||||
if (finish_start_duration != null) {
|
||||
finish_start_duration.setText(calcDuration(getRaceState().getStartTime(), getRaceState().getFinishingTime()));
|
||||
finish_start_duration.setText(calcDuration(startTime, finishingTime));
|
||||
}
|
||||
|
||||
TextView finish_end_time = ViewHolder.get(getView(), R.id.race_finish_end_time);
|
||||
if (finish_end_time != null) {
|
||||
finish_end_time.setText(dateFormat.format(getRaceState().getFinishedTime().asDate()));
|
||||
finish_end_time.setText(dateFormat.format(finishedTime.getTime()));
|
||||
}
|
||||
|
||||
TextView finish_end_duration = ViewHolder.get(getView(), R.id.race_finish_end_duration);
|
||||
if (finish_end_duration != null) {
|
||||
finish_end_duration.setText(calcDuration(getRaceState().getStartTime(), getRaceState().getFinishedTime()));
|
||||
finish_end_duration.setText(calcDuration(startTime, finishedTime));
|
||||
}
|
||||
|
||||
TextView finish_duration = ViewHolder.get(getView(), R.id.race_finish_duration);
|
||||
if (finish_duration != null) {
|
||||
finish_duration.setText(calcDuration(getRaceState().getFinishingTime(), getRaceState().getFinishedTime()));
|
||||
finish_duration.setText(calcDuration(finishingTime, finishedTime));
|
||||
}
|
||||
|
||||
View region_wind = ViewHolder.get(getView(), R.id.region_wind);
|
||||
@@ -102,7 +120,7 @@ public abstract class BaseFinishedRaceFragment<ProcedureType extends RacingProce
|
||||
|
||||
TextView direction = ViewHolder.get(getView(), R.id.wind_direction);
|
||||
if (direction != null) {
|
||||
String wind_direction = String.format(getString(R.string.race_summary_wind_direction_value), wind.getFrom());
|
||||
String wind_direction = String.format(getString(R.string.race_summary_wind_direction_value), wind.getFrom().getDegrees());
|
||||
direction.setText(wind_direction);
|
||||
}
|
||||
|
||||
@@ -126,29 +144,31 @@ public abstract class BaseFinishedRaceFragment<ProcedureType extends RacingProce
|
||||
|
||||
}
|
||||
|
||||
private String calcDuration(TimePoint from, TimePoint to) {
|
||||
private String calcDuration(Calendar from, Calendar to) {
|
||||
String retValue;
|
||||
|
||||
Duration duration = from.until(to);
|
||||
long millis = to.getTimeInMillis() - from.getTimeInMillis();
|
||||
|
||||
int sec = (int) Math.ceil(duration.asSeconds());
|
||||
int min = sec / 60;
|
||||
sec = sec - min * 60;
|
||||
long min = millis / (1000 * 60);
|
||||
long sec = (millis - (min * 60 * 1000)) / 1000;
|
||||
|
||||
String time = doubleZero(min) + ":" + doubleZero(sec);
|
||||
retValue = String.format(getString(R.string.race_summary_time), time);
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
private String doubleZero(int value) {
|
||||
String retValue = String.valueOf(value);
|
||||
|
||||
int len = retValue.length();
|
||||
for (int i = len; i < 2; i++) {
|
||||
retValue = String.valueOf(sec) + "\"";
|
||||
if (retValue.length() == 2) {
|
||||
retValue = "0" + retValue;
|
||||
}
|
||||
if (min > 0) {
|
||||
retValue = String.valueOf(min) + "' " + retValue;
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
private Calendar floorTime(Calendar calendar) {
|
||||
if (calendar == null) {
|
||||
calendar = Calendar.getInstance();
|
||||
}
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
return calendar;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user