mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-22 13:45:42 +00:00
# formatting
This commit is contained in:
+5
-5
@@ -25,7 +25,7 @@ public class RaceStateImpl implements RaceState, RaceLogChangedListener {
|
||||
|
||||
protected RaceLogRaceStatus status;
|
||||
protected PassAwareRaceLog raceLog;
|
||||
protected Set<RaceStateChangedListener> changedListeners;
|
||||
protected Set<RaceStateChangedListener> stateChangedListeners;
|
||||
|
||||
private RaceLogChangedVisitor raceLogListener;
|
||||
private RaceStatusAnalyzer statusAnalyzer;
|
||||
@@ -34,7 +34,7 @@ public class RaceStateImpl implements RaceState, RaceLogChangedListener {
|
||||
public RaceStateImpl(PassAwareRaceLog raceLog) {
|
||||
this.raceLog = raceLog;
|
||||
this.status = RaceLogRaceStatus.UNKNOWN;
|
||||
this.changedListeners = new HashSet<RaceStateChangedListener>();
|
||||
this.stateChangedListeners = new HashSet<RaceStateChangedListener>();
|
||||
|
||||
this.raceLogListener = new RaceLogChangedVisitor(this);
|
||||
this.raceLog.addListener(raceLogListener);
|
||||
@@ -61,17 +61,17 @@ public class RaceStateImpl implements RaceState, RaceLogChangedListener {
|
||||
}
|
||||
|
||||
private void notifyListeners() {
|
||||
for (RaceStateChangedListener listener : changedListeners) {
|
||||
for (RaceStateChangedListener listener : stateChangedListeners) {
|
||||
listener.onRaceStateChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerListener(RaceStateChangedListener listener) {
|
||||
changedListeners.add(listener);
|
||||
stateChangedListeners.add(listener);
|
||||
}
|
||||
|
||||
public void unregisterListener(RaceStateChangedListener listener) {
|
||||
changedListeners.remove(listener);
|
||||
stateChangedListeners.remove(listener);
|
||||
}
|
||||
|
||||
public TimePoint getStartTime() {
|
||||
|
||||
+164
-174
@@ -27,199 +27,189 @@ import com.sap.sailing.racecommittee.app.ui.fragments.RaceInfoFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.lists.ManagedRaceListFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.RaceInfoListener;
|
||||
|
||||
public class RacingActivity extends TwoPaneActivity implements RaceInfoListener /*implements ResetTimeListener,
|
||||
StartModeSelectionListener, PathfinderSelectionListener, GateLineOpeningTimeSelectionListener, CourseDesignSelectionListener*/ {
|
||||
// private final static String TAG = RacingActivity.class.getName();
|
||||
|
||||
private final static String ListFragmentTag = RacingActivity.class.getName() + ".ManagedRaceListFragment";
|
||||
|
||||
/**
|
||||
* Selection list of all races
|
||||
*/
|
||||
private ManagedRaceListFragment listFragment;
|
||||
|
||||
/**
|
||||
* Container fragment for currently selected race
|
||||
*/
|
||||
private RaceInfoFragment infoFragment;
|
||||
|
||||
private ReadonlyDataManager dataManager;
|
||||
|
||||
@Override
|
||||
protected boolean onHomeClicked() {
|
||||
fadeActivity(LoginActivity.class);
|
||||
return true;
|
||||
}
|
||||
|
||||
public class RacingActivity extends TwoPaneActivity implements RaceInfoListener /*
|
||||
* implements ResetTimeListener,
|
||||
* StartModeSelectionListener,
|
||||
* PathfinderSelectionListener,
|
||||
* GateLineOpeningTimeSelectionListener,
|
||||
* CourseDesignSelectionListener
|
||||
*/{
|
||||
// private final static String TAG = RacingActivity.class.getName();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
dataManager = DataManager.create(this);
|
||||
private final static String ListFragmentTag = RacingActivity.class.getName() + ".ManagedRaceListFragment";
|
||||
|
||||
getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
setContentView(R.layout.racing_view);
|
||||
setProgressBarIndeterminateVisibility(false);
|
||||
|
||||
listFragment = getListFragment();
|
||||
|
||||
Serializable courseAreaId = getCourseAreaIdFromIntent();
|
||||
if (courseAreaId == null) {
|
||||
throw new IllegalStateException("There was no course area id transmitted...");
|
||||
}
|
||||
CourseArea courseArea = dataManager.getDataStore().getCourseArea(courseAreaId);
|
||||
if (courseArea == null) {
|
||||
throw new IllegalStateException("Course Area was not found.");
|
||||
}
|
||||
|
||||
setupTitle(courseArea);
|
||||
loadRaces(courseArea);
|
||||
//StaticVibrator.prepareVibrator(this);
|
||||
}
|
||||
/**
|
||||
* Selection list of all races
|
||||
*/
|
||||
private ManagedRaceListFragment listFragment;
|
||||
|
||||
private ManagedRaceListFragment getListFragment() {
|
||||
Fragment fragment = getFragmentManager().findFragmentByTag(ListFragmentTag);
|
||||
// on first create add race list fragment
|
||||
if (fragment == null) {
|
||||
fragment = createListFragment();
|
||||
}
|
||||
return (ManagedRaceListFragment) fragment;
|
||||
}
|
||||
/**
|
||||
* Container fragment for currently selected race
|
||||
*/
|
||||
private RaceInfoFragment infoFragment;
|
||||
|
||||
private ReadonlyDataManager dataManager;
|
||||
|
||||
private Fragment createListFragment() {
|
||||
Fragment fragment = new ManagedRaceListFragment();
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.add(R.id.races_and_details_left, fragment, ListFragmentTag);
|
||||
transaction.setTransition(FragmentTransaction.TRANSIT_NONE);
|
||||
transaction.commit();
|
||||
return fragment;
|
||||
}
|
||||
@Override
|
||||
protected boolean onHomeClicked() {
|
||||
fadeActivity(LoginActivity.class);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
dataManager = DataManager.create(this);
|
||||
|
||||
private Serializable getCourseAreaIdFromIntent() {
|
||||
if (getIntent() == null || getIntent().getExtras() == null) {
|
||||
String msg = "Expected an intent carrying event extras.";
|
||||
Log.e(getClass().getName(), msg);
|
||||
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
|
||||
return null;
|
||||
}
|
||||
|
||||
final Serializable courseId = getIntent().getExtras().getSerializable(AppConstants.COURSE_AREA_UUID_KEY);
|
||||
if (courseId == null) {
|
||||
String msg = "Expected an intent carrying the course area id.";
|
||||
Log.e(getClass().getName(), msg);
|
||||
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
|
||||
return null;
|
||||
}
|
||||
return courseId;
|
||||
}
|
||||
getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
setContentView(R.layout.racing_view);
|
||||
setProgressBarIndeterminateVisibility(false);
|
||||
|
||||
private void setupTitle(CourseArea courseArea) {
|
||||
TextView label = (TextView) findViewById(R.id.textListHeader);
|
||||
label.setText(String.format(getString(R.string.racingview_header), courseArea.getName()));
|
||||
}
|
||||
|
||||
private void loadRaces(final CourseArea courseArea) {
|
||||
setProgressBarIndeterminateVisibility(true);
|
||||
|
||||
dataManager.loadRaces(courseArea.getId(), new LoadClient<Collection<ManagedRace>>() {
|
||||
public void onLoadSucceded(Collection<ManagedRace> data) {
|
||||
onLoadRacesSucceded(courseArea, data);
|
||||
listFragment = getListFragment();
|
||||
|
||||
}
|
||||
public void onLoadFailed(Exception reason) {
|
||||
onLoadRacesFailed(courseArea, reason);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onLoadRacesSucceded(CourseArea courseArea, Collection<ManagedRace> data) {
|
||||
setProgressBarIndeterminateVisibility(false);
|
||||
|
||||
registerOnService(data);
|
||||
listFragment.setupOn(data);
|
||||
|
||||
Toast.makeText(RacingActivity.this,
|
||||
"Loaded " + data.size() + " races for course " + courseArea.getId(),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
Serializable courseAreaId = getCourseAreaIdFromIntent();
|
||||
if (courseAreaId == null) {
|
||||
throw new IllegalStateException("There was no course area id transmitted...");
|
||||
}
|
||||
CourseArea courseArea = dataManager.getDataStore().getCourseArea(courseAreaId);
|
||||
if (courseArea == null) {
|
||||
throw new IllegalStateException("Course Area was not found.");
|
||||
}
|
||||
|
||||
private void onLoadRacesFailed(final CourseArea courseArea, Exception reason) {
|
||||
setProgressBarIndeterminateVisibility(false);
|
||||
showLoadFailedDialog(courseArea, reason.getMessage());
|
||||
}
|
||||
|
||||
private void registerOnService(Collection<ManagedRace> races) {
|
||||
// since the service is the long-living component
|
||||
// he should decide whether these races are already
|
||||
// registered or not.
|
||||
for (ManagedRace race : races) {
|
||||
Intent registerIntent = new Intent(AppConstants.REGISTER_RACE_ACTION);
|
||||
registerIntent.putExtra(AppConstants.RACE_ID_KEY, race.getId());
|
||||
this.startService(registerIntent);
|
||||
}
|
||||
}
|
||||
|
||||
private void showLoadFailedDialog(final CourseArea courseArea, String message) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(String.format("There was an error loading the requested data: %s\nDo you want to retry?", message))
|
||||
.setTitle("Load failure")
|
||||
.setIcon(R.drawable.ic_dialog_alert_holo_light)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton("Retry", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
loadRaces(courseArea);
|
||||
}
|
||||
})
|
||||
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
public void onRaceItemClicked(ManagedRace managedRace) {
|
||||
this.infoFragment = new RaceInfoFragment();
|
||||
infoFragment.setArguments(RaceFragment.createArguments(managedRace));
|
||||
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.setCustomAnimations(R.animator.slide_in, R.animator.slide_out);
|
||||
transaction.replace(R.id.races_and_details_right, infoFragment);
|
||||
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
||||
transaction.commit();
|
||||
getRightLayout().setVisibility(View.VISIBLE);
|
||||
}
|
||||
setupTitle(courseArea);
|
||||
loadRaces(courseArea);
|
||||
// StaticVibrator.prepareVibrator(this);
|
||||
}
|
||||
|
||||
private ManagedRaceListFragment getListFragment() {
|
||||
Fragment fragment = getFragmentManager().findFragmentByTag(ListFragmentTag);
|
||||
// on first create add race list fragment
|
||||
if (fragment == null) {
|
||||
fragment = createListFragment();
|
||||
}
|
||||
return (ManagedRaceListFragment) fragment;
|
||||
}
|
||||
|
||||
public void onResetTime() {
|
||||
infoFragment.onResetTime();
|
||||
}
|
||||
private Fragment createListFragment() {
|
||||
Fragment fragment = new ManagedRaceListFragment();
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.add(R.id.races_and_details_left, fragment, ListFragmentTag);
|
||||
transaction.setTransition(FragmentTransaction.TRANSIT_NONE);
|
||||
transaction.commit();
|
||||
return fragment;
|
||||
}
|
||||
|
||||
/*public void onResetTimeClick() {
|
||||
infoFragment.displayResetTimeFragment();
|
||||
}
|
||||
private Serializable getCourseAreaIdFromIntent() {
|
||||
if (getIntent() == null || getIntent().getExtras() == null) {
|
||||
String msg = "Expected an intent carrying event extras.";
|
||||
Log.e(getClass().getName(), msg);
|
||||
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onStartModeSelected() {
|
||||
infoFragment.startModeSelected();
|
||||
}
|
||||
final Serializable courseId = getIntent().getExtras().getSerializable(AppConstants.COURSE_AREA_UUID_KEY);
|
||||
if (courseId == null) {
|
||||
String msg = "Expected an intent carrying the course area id.";
|
||||
Log.e(getClass().getName(), msg);
|
||||
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
|
||||
return null;
|
||||
}
|
||||
return courseId;
|
||||
}
|
||||
|
||||
private void setupTitle(CourseArea courseArea) {
|
||||
TextView label = (TextView) findViewById(R.id.textListHeader);
|
||||
label.setText(String.format(getString(R.string.racingview_header), courseArea.getName()));
|
||||
}
|
||||
|
||||
public void onPathfinderSelected() {
|
||||
infoFragment.pathfinderSelected();
|
||||
}
|
||||
private void loadRaces(final CourseArea courseArea) {
|
||||
setProgressBarIndeterminateVisibility(true);
|
||||
|
||||
dataManager.loadRaces(courseArea.getId(), new LoadClient<Collection<ManagedRace>>() {
|
||||
public void onLoadSucceded(Collection<ManagedRace> data) {
|
||||
onLoadRacesSucceded(courseArea, data);
|
||||
|
||||
public void onLineOpeningTimeSelected() {
|
||||
infoFragment.gateLineOpeningTimeSelected();
|
||||
}
|
||||
}
|
||||
|
||||
public void onLoadFailed(Exception reason) {
|
||||
onLoadRacesFailed(courseArea, reason);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCourseDesignSelected() {
|
||||
infoFragment.courseDesignSelected();
|
||||
}*/
|
||||
private void onLoadRacesSucceded(CourseArea courseArea, Collection<ManagedRace> data) {
|
||||
setProgressBarIndeterminateVisibility(false);
|
||||
|
||||
registerOnService(data);
|
||||
listFragment.setupOn(data);
|
||||
|
||||
Toast.makeText(RacingActivity.this, "Loaded " + data.size() + " races for course " + courseArea.getId(),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void onLoadRacesFailed(final CourseArea courseArea, Exception reason) {
|
||||
setProgressBarIndeterminateVisibility(false);
|
||||
showLoadFailedDialog(courseArea, reason.getMessage());
|
||||
}
|
||||
|
||||
private void registerOnService(Collection<ManagedRace> races) {
|
||||
// since the service is the long-living component
|
||||
// he should decide whether these races are already
|
||||
// registered or not.
|
||||
for (ManagedRace race : races) {
|
||||
Intent registerIntent = new Intent(AppConstants.REGISTER_RACE_ACTION);
|
||||
registerIntent.putExtra(AppConstants.RACE_ID_KEY, race.getId());
|
||||
this.startService(registerIntent);
|
||||
}
|
||||
}
|
||||
|
||||
private void showLoadFailedDialog(final CourseArea courseArea, String message) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(
|
||||
String.format("There was an error loading the requested data: %s\nDo you want to retry?", message))
|
||||
.setTitle("Load failure").setIcon(R.drawable.ic_dialog_alert_holo_light).setCancelable(true)
|
||||
.setPositiveButton("Retry", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
loadRaces(courseArea);
|
||||
}
|
||||
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
public void onRaceItemClicked(ManagedRace managedRace) {
|
||||
this.infoFragment = new RaceInfoFragment();
|
||||
infoFragment.setArguments(RaceFragment.createArguments(managedRace));
|
||||
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.setCustomAnimations(R.animator.slide_in, R.animator.slide_out);
|
||||
transaction.replace(R.id.races_and_details_right, infoFragment);
|
||||
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
||||
transaction.commit();
|
||||
getRightLayout().setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void onResetTime() {
|
||||
infoFragment.onResetTime();
|
||||
}
|
||||
|
||||
/*
|
||||
* public void onResetTimeClick() { infoFragment.displayResetTimeFragment(); }
|
||||
*
|
||||
* public void onStartModeSelected() { infoFragment.startModeSelected(); }
|
||||
*
|
||||
*
|
||||
* public void onPathfinderSelected() { infoFragment.pathfinderSelected(); }
|
||||
*
|
||||
*
|
||||
* public void onLineOpeningTimeSelected() { infoFragment.gateLineOpeningTimeSelected(); }
|
||||
*
|
||||
*
|
||||
* @Override public void onCourseDesignSelected() { infoFragment.courseDesignSelected(); }
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user