mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 22:37:15 +00:00
formatting only
This commit is contained in:
1 parent
11c772741d
commit
822bb774f5
1 file changed
+212
-274
+212
-274
@@ -49,303 +49,244 @@ import com.sap.sse.common.Util;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
public class ESSCourseDesignDialog extends RaceDialogFragment {
|
||||
// private final static String TAG =
|
||||
// ESSCourseDesignDialogFragment.class.getName();
|
||||
// private final static String TAG =
|
||||
// ESSCourseDesignDialogFragment.class.getName();
|
||||
|
||||
private static int MarksLoaderId = 0;
|
||||
private static int MarksLoaderId = 0;
|
||||
|
||||
private List<Mark> aMarkList;
|
||||
private MarkGridAdapter gridAdapter;
|
||||
private List<CourseListDataElement> courseElements;
|
||||
private List<CourseListDataElement> previousCourseElements;
|
||||
private DraggableCourseElementListAdapter courseElementAdapter;
|
||||
private CourseElementListAdapter previousCourseElementAdapter;
|
||||
private DragSortListView newCourseListView;
|
||||
private ListView previousCourseListView;
|
||||
private List<Mark> aMarkList;
|
||||
private MarkGridAdapter gridAdapter;
|
||||
private List<CourseListDataElement> courseElements;
|
||||
private List<CourseListDataElement> previousCourseElements;
|
||||
private DraggableCourseElementListAdapter courseElementAdapter;
|
||||
private CourseElementListAdapter previousCourseElementAdapter;
|
||||
private DragSortListView newCourseListView;
|
||||
private ListView previousCourseListView;
|
||||
|
||||
private DragSortController dragSortController;
|
||||
private DragSortController dragSortController;
|
||||
|
||||
private Button publishButton;
|
||||
private Button unpublishButton;
|
||||
private Button takePreviousButton;
|
||||
private Button publishButton;
|
||||
private Button unpublishButton;
|
||||
private Button takePreviousButton;
|
||||
|
||||
private ReadonlyDataManager dataManager;
|
||||
private ReadonlyDataManager dataManager;
|
||||
|
||||
private int dragStartMode = DragSortController.ON_DRAG;
|
||||
private boolean removeEnabled = true;
|
||||
private int removeMode = DragSortController.FLING_REMOVE;
|
||||
private boolean sortEnabled = true;
|
||||
private boolean dragEnabled = true;
|
||||
private int dragStartMode = DragSortController.ON_DRAG;
|
||||
private boolean removeEnabled = true;
|
||||
private int removeMode = DragSortController.FLING_REMOVE;
|
||||
private boolean sortEnabled = true;
|
||||
private boolean dragEnabled = true;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.race_choose_ess_course_design_view,
|
||||
container);
|
||||
}
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.race_choose_ess_course_design_view, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getDialog().setTitle(
|
||||
getActivity().getText(R.string.course_design_dialog_title));
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getDialog().setTitle(getActivity().getText(R.string.course_design_dialog_title));
|
||||
dataManager = DataManager.create(getActivity());
|
||||
aMarkList = new ArrayList<Mark>();
|
||||
courseElements = new ArrayList<CourseListDataElement>();
|
||||
previousCourseElements = new ArrayList<CourseListDataElement>();
|
||||
gridAdapter = new MarkGridAdapter(getActivity(), aMarkList, ESSMarkImageHelper.getInstance());
|
||||
courseElementAdapter = new DraggableCourseElementListAdapter(getActivity(), courseElements,
|
||||
ESSMarkImageHelper.getInstance());
|
||||
previousCourseElementAdapter = new CourseElementListAdapter(getActivity(), previousCourseElements,
|
||||
ESSMarkImageHelper.getInstance());
|
||||
loadMarks();
|
||||
fillPreviousCourseElementsWithLastPublishedCourseDesign();
|
||||
GridView gridView = (GridView) getView().findViewById(R.id.gridViewAssets);
|
||||
gridView.setAdapter(gridAdapter);
|
||||
gridView.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
||||
dataManager = DataManager.create(getActivity());
|
||||
public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
|
||||
Mark mark = (Mark) gridAdapter.getItem(position);
|
||||
Log.i("CourseDesign", "Grid is clicked at position " + position + " for buoy " + mark.getName());
|
||||
onMarkClickedOnGrid(mark);
|
||||
}
|
||||
});
|
||||
newCourseListView = (DragSortListView) getView().findViewById(R.id.listViewNewCourse);
|
||||
newCourseListView.setAdapter(courseElementAdapter);
|
||||
newCourseListView.setDropListener(new DragSortListView.DropListener() {
|
||||
@Override
|
||||
public void drop(int from, int to) {
|
||||
if (from != to) {
|
||||
CourseListDataElement item = courseElementAdapter.getItem(from);
|
||||
courseElementAdapter.remove(item);
|
||||
courseElementAdapter.insert(item, to);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
aMarkList = new ArrayList<Mark>();
|
||||
courseElements = new ArrayList<CourseListDataElement>();
|
||||
previousCourseElements = new ArrayList<CourseListDataElement>();
|
||||
newCourseListView.setRemoveListener(new DragSortListView.RemoveListener() {
|
||||
@Override
|
||||
public void remove(int toBeRemoved) {
|
||||
CourseListDataElement item = courseElementAdapter.getItem(toBeRemoved);
|
||||
courseElementAdapter.remove(item);
|
||||
}
|
||||
});
|
||||
|
||||
gridAdapter = new MarkGridAdapter(getActivity(), aMarkList,
|
||||
ESSMarkImageHelper.getInstance());
|
||||
courseElementAdapter = new DraggableCourseElementListAdapter(
|
||||
getActivity(), courseElements, ESSMarkImageHelper.getInstance());
|
||||
previousCourseElementAdapter = new CourseElementListAdapter(
|
||||
getActivity(), previousCourseElements,
|
||||
ESSMarkImageHelper.getInstance());
|
||||
newCourseListView.setOnItemLongClickListener(new OnItemLongClickListener() {
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
|
||||
CourseListDataElement courseElement = courseElementAdapter.getItem(position);
|
||||
createPassingInstructionDialog(courseElement);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
loadMarks();
|
||||
fillPreviousCourseElementsWithLastPublishedCourseDesign();
|
||||
dragSortController = buildDragSortController(newCourseListView);
|
||||
newCourseListView.setFloatViewManager(dragSortController);
|
||||
newCourseListView.setOnTouchListener(dragSortController);
|
||||
newCourseListView.setDragEnabled(dragEnabled);
|
||||
|
||||
GridView gridView = (GridView) getView().findViewById(
|
||||
R.id.gridViewAssets);
|
||||
gridView.setAdapter(gridAdapter);
|
||||
if (getRace().getCourseDesign() != null) {
|
||||
fillCourseElementsInList();
|
||||
}
|
||||
|
||||
gridView.setOnItemClickListener(new OnItemClickListener() {
|
||||
previousCourseListView = (ListView) getView().findViewById(R.id.listViewPreviousCourse);
|
||||
previousCourseListView.setAdapter(previousCourseElementAdapter);
|
||||
|
||||
public void onItemClick(AdapterView<?> arg0, View view,
|
||||
int position, long arg3) {
|
||||
Mark mark = (Mark) gridAdapter.getItem(position);
|
||||
Log.i("CourseDesign", "Grid is clicked at position " + position
|
||||
+ " for buoy " + mark.getName());
|
||||
onMarkClickedOnGrid(mark);
|
||||
}
|
||||
takePreviousButton = (Button) getView().findViewById(R.id.takePreviousCourseDesignButton);
|
||||
takePreviousButton.setOnClickListener(new OnClickListener() {
|
||||
|
||||
});
|
||||
public void onClick(View arg0) {
|
||||
if (!previousCourseElements.isEmpty()) {
|
||||
if (!courseElements.isEmpty()) {
|
||||
createUsePreviousCourseDialog();
|
||||
} else {
|
||||
copyPreviousToNewCourseDesign();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getActivity(), "No course available to copy", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
newCourseListView = (DragSortListView) getView().findViewById(
|
||||
R.id.listViewNewCourse);
|
||||
newCourseListView.setAdapter(courseElementAdapter);
|
||||
newCourseListView.setDropListener(new DragSortListView.DropListener() {
|
||||
publishButton = (Button) getView().findViewById(R.id.publishCourseDesignButton);
|
||||
publishButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View arg0) {
|
||||
try {
|
||||
CourseBase courseData = convertCourseElementsToACourseData();
|
||||
sendCourseDataAndDismiss(courseData);
|
||||
} catch (IllegalStateException ex) {
|
||||
if (ex.getMessage().equals("Missing second mark")) {
|
||||
Toast.makeText(getActivity(),
|
||||
"The selected passing instructions require two buoys. Please select the second buoy.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
} else if (ex.getMessage().equals("Each waypoints needs passing instructions")) {
|
||||
Toast.makeText(
|
||||
getActivity(),
|
||||
"A waypoint has no passing instructions. Please select the passing instruction by clicking long on the waypoint.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
Toast.makeText(getActivity(), "The course design has to have at least one waypoint.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void drop(int from, int to) {
|
||||
if (from != to) {
|
||||
CourseListDataElement item = courseElementAdapter
|
||||
.getItem(from);
|
||||
courseElementAdapter.remove(item);
|
||||
courseElementAdapter.insert(item, to);
|
||||
}
|
||||
}
|
||||
});
|
||||
unpublishButton = (Button) getView().findViewById(R.id.unpublishCourseDesignButton);
|
||||
unpublishButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
CourseBase emptyCourse = new CourseDataImpl("Unpublished course design");
|
||||
sendCourseDataAndDismiss(emptyCourse);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
newCourseListView
|
||||
.setRemoveListener(new DragSortListView.RemoveListener() {
|
||||
/**
|
||||
* Creates a DragSortController and thereby defines the behavior of the drag sort list
|
||||
*/
|
||||
public DragSortController buildDragSortController(DragSortListView dragSortListView) {
|
||||
DragSortController controller = new DragSortController(dragSortListView);
|
||||
controller.setDragHandleId(R.id.drag_handle);
|
||||
controller.setFlingHandleId(R.id.drag_handle);
|
||||
controller.setRemoveEnabled(removeEnabled);
|
||||
controller.setSortEnabled(sortEnabled);
|
||||
controller.setDragInitMode(dragStartMode);
|
||||
controller.setRemoveMode(removeMode);
|
||||
controller.setBackgroundColor(getActivity().getResources().getColor(R.color.welter_medium_blue));
|
||||
return controller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(int toBeRemoved) {
|
||||
CourseListDataElement item = courseElementAdapter
|
||||
.getItem(toBeRemoved);
|
||||
courseElementAdapter.remove(item);
|
||||
}
|
||||
});
|
||||
private void fillPreviousCourseElementsWithLastPublishedCourseDesign() {
|
||||
CourseBase lastPublishedCourseDesign = InMemoryDataStore.INSTANCE.getLastPublishedCourseDesign();
|
||||
if (lastPublishedCourseDesign != null) {
|
||||
fillPreviousCourseElementsInList(lastPublishedCourseDesign);
|
||||
}
|
||||
}
|
||||
|
||||
newCourseListView
|
||||
.setOnItemLongClickListener(new OnItemLongClickListener() {
|
||||
private void loadMarks() {
|
||||
Loader<?> marksLoader = getLoaderManager().restartLoader(MarksLoaderId, null,
|
||||
dataManager.createMarksLoader(getRace(), new LoadClient<Collection<Mark>>() {
|
||||
@Override
|
||||
public void onLoadFailed(Exception reason) {
|
||||
Toast.makeText(getActivity(), String.format("Marks: %s", reason.toString()), Toast.LENGTH_LONG)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> arg0,
|
||||
View arg1, int position, long arg3) {
|
||||
CourseListDataElement courseElement = courseElementAdapter
|
||||
.getItem(position);
|
||||
createPassingInstructionDialog(courseElement);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onLoadSucceeded(Collection<Mark> data, boolean isCached) {
|
||||
onLoadMarksSucceeded(data);
|
||||
}
|
||||
}));
|
||||
// ignore any cached results and force a remote load of the marks,
|
||||
// because we always need the most current.
|
||||
marksLoader.forceLoad();
|
||||
}
|
||||
|
||||
dragSortController = buildDragSortController(newCourseListView);
|
||||
newCourseListView.setFloatViewManager(dragSortController);
|
||||
newCourseListView.setOnTouchListener(dragSortController);
|
||||
newCourseListView.setDragEnabled(dragEnabled);
|
||||
protected void onLoadMarksSucceeded(Collection<Mark> data) {
|
||||
aMarkList.clear();
|
||||
aMarkList.addAll(data);
|
||||
Collections.sort(aMarkList, new NaturalNamedComparator());
|
||||
gridAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
if (getRace().getCourseDesign() != null) {
|
||||
fillCourseElementsInList();
|
||||
}
|
||||
private void fillPreviousCourseElementsInList(CourseBase previousCourseData) {
|
||||
if (previousCourseData != null) {
|
||||
previousCourseElements.clear();
|
||||
previousCourseElements.addAll(convertCourseDesignToCourseElements(previousCourseData));
|
||||
previousCourseElementAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
previousCourseListView = (ListView) getView().findViewById(
|
||||
R.id.listViewPreviousCourse);
|
||||
previousCourseListView.setAdapter(previousCourseElementAdapter);
|
||||
private void fillCourseElementsInList() {
|
||||
courseElements.clear();
|
||||
courseElements.addAll(convertCourseDesignToCourseElements(getRace().getCourseDesign()));
|
||||
courseElementAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
takePreviousButton = (Button) getView().findViewById(R.id.takePreviousCourseDesignButton);
|
||||
takePreviousButton.setOnClickListener(new OnClickListener() {
|
||||
protected List<CourseListDataElement> convertCourseDesignToCourseElements(CourseBase courseData) {
|
||||
List<CourseListDataElement> elementList = new ArrayList<CourseListDataElement>();
|
||||
for (Waypoint waypoint : courseData.getWaypoints()) {
|
||||
ControlPoint controlPoint = waypoint.getControlPoint();
|
||||
if (controlPoint instanceof Mark) {
|
||||
CourseListDataElement element = new CourseListDataElement();
|
||||
element.setLeftMark((Mark) controlPoint);
|
||||
element.setPassingInstructions(waypoint.getPassingInstructions());
|
||||
elementList.add(element);
|
||||
} else if (controlPoint instanceof ControlPointWithTwoMarks) {
|
||||
ControlPointWithTwoMarks controlPointTwoMarks = (ControlPointWithTwoMarks) controlPoint;
|
||||
CourseListDataElement element = new CourseListDataElement();
|
||||
element.setLeftMark(controlPointTwoMarks.getLeft());
|
||||
element.setRightMark(controlPointTwoMarks.getRight());
|
||||
element.setPassingInstructions(waypoint.getPassingInstructions());
|
||||
elementList.add(element);
|
||||
}
|
||||
}
|
||||
return elementList;
|
||||
}
|
||||
|
||||
public void onClick(View arg0) {
|
||||
if (!previousCourseElements.isEmpty()) {
|
||||
if (!courseElements.isEmpty()) {
|
||||
createUsePreviousCourseDialog();
|
||||
} else {
|
||||
copyPreviousToNewCourseDesign();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getActivity(),
|
||||
"No course available to copy", Toast.LENGTH_LONG)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
publishButton = (Button) getView().findViewById(
|
||||
R.id.publishCourseDesignButton);
|
||||
publishButton.setOnClickListener(new OnClickListener() {
|
||||
|
||||
public void onClick(View arg0) {
|
||||
try {
|
||||
CourseBase courseData = convertCourseElementsToACourseData();
|
||||
sendCourseDataAndDismiss(courseData);
|
||||
} catch (IllegalStateException ex) {
|
||||
if (ex.getMessage().equals("Missing second mark")) {
|
||||
Toast.makeText(
|
||||
getActivity(),
|
||||
"The selected passing instructions require two buoys. Please select the second buoy.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
} else if (ex.getMessage().equals(
|
||||
"Each waypoints needs passing instructions")) {
|
||||
Toast.makeText(
|
||||
getActivity(),
|
||||
"A waypoint has no passing instructions. Please select the passing instruction by clicking long on the waypoint.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
} catch (IllegalArgumentException ex) {
|
||||
Toast.makeText(
|
||||
getActivity(),
|
||||
"The course design has to have at least one waypoint.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
unpublishButton = (Button) getView().findViewById(
|
||||
R.id.unpublishCourseDesignButton);
|
||||
unpublishButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
CourseBase emptyCourse = new CourseDataImpl(
|
||||
"Unpublished course design");
|
||||
sendCourseDataAndDismiss(emptyCourse);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DragSortController and thereby defines the behavior of the drag
|
||||
* sort list
|
||||
*/
|
||||
public DragSortController buildDragSortController(
|
||||
DragSortListView dragSortListView) {
|
||||
DragSortController controller = new DragSortController(dragSortListView);
|
||||
controller.setDragHandleId(R.id.drag_handle);
|
||||
controller.setFlingHandleId(R.id.drag_handle);
|
||||
controller.setRemoveEnabled(removeEnabled);
|
||||
controller.setSortEnabled(sortEnabled);
|
||||
controller.setDragInitMode(dragStartMode);
|
||||
controller.setRemoveMode(removeMode);
|
||||
controller.setBackgroundColor(getActivity().getResources().getColor(
|
||||
R.color.welter_medium_blue));
|
||||
return controller;
|
||||
}
|
||||
|
||||
private void fillPreviousCourseElementsWithLastPublishedCourseDesign() {
|
||||
CourseBase lastPublishedCourseDesign = InMemoryDataStore.INSTANCE
|
||||
.getLastPublishedCourseDesign();
|
||||
if (lastPublishedCourseDesign != null) {
|
||||
fillPreviousCourseElementsInList(lastPublishedCourseDesign);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadMarks() {
|
||||
Loader<?> marksLoader = getLoaderManager().restartLoader(
|
||||
MarksLoaderId,
|
||||
null,
|
||||
dataManager.createMarksLoader(getRace(),
|
||||
new LoadClient<Collection<Mark>>() {
|
||||
@Override
|
||||
public void onLoadFailed(Exception reason) {
|
||||
Toast.makeText(
|
||||
getActivity(),
|
||||
String.format("Marks: %s",
|
||||
reason.toString()),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadSucceeded(Collection<Mark> data,
|
||||
boolean isCached) {
|
||||
onLoadMarksSucceeded(data);
|
||||
}
|
||||
}));
|
||||
// ignore any cached results and force a remote load of the marks,
|
||||
// because we always need the most current.
|
||||
marksLoader.forceLoad();
|
||||
}
|
||||
|
||||
protected void onLoadMarksSucceeded(Collection<Mark> data) {
|
||||
aMarkList.clear();
|
||||
aMarkList.addAll(data);
|
||||
Collections.sort(aMarkList, new NaturalNamedComparator());
|
||||
gridAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void fillPreviousCourseElementsInList(CourseBase previousCourseData) {
|
||||
if (previousCourseData != null) {
|
||||
previousCourseElements.clear();
|
||||
previousCourseElements
|
||||
.addAll(convertCourseDesignToCourseElements(previousCourseData));
|
||||
previousCourseElementAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void fillCourseElementsInList() {
|
||||
courseElements.clear();
|
||||
courseElements.addAll(convertCourseDesignToCourseElements(getRace()
|
||||
.getCourseDesign()));
|
||||
courseElementAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
protected List<CourseListDataElement> convertCourseDesignToCourseElements(
|
||||
CourseBase courseData) {
|
||||
List<CourseListDataElement> elementList = new ArrayList<CourseListDataElement>();
|
||||
|
||||
for (Waypoint waypoint : courseData.getWaypoints()) {
|
||||
ControlPoint controlPoint = waypoint.getControlPoint();
|
||||
|
||||
if (controlPoint instanceof Mark) {
|
||||
CourseListDataElement element = new CourseListDataElement();
|
||||
element.setLeftMark((Mark) controlPoint);
|
||||
element.setPassingInstructions(waypoint
|
||||
.getPassingInstructions());
|
||||
elementList.add(element);
|
||||
} else if (controlPoint instanceof ControlPointWithTwoMarks) {
|
||||
ControlPointWithTwoMarks controlPointTwoMarks = (ControlPointWithTwoMarks) controlPoint;
|
||||
CourseListDataElement element = new CourseListDataElement();
|
||||
element.setLeftMark(controlPointTwoMarks.getLeft());
|
||||
element.setRightMark(controlPointTwoMarks.getRight());
|
||||
element.setPassingInstructions(waypoint
|
||||
.getPassingInstructions());
|
||||
elementList.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
return elementList;
|
||||
}
|
||||
|
||||
protected void sendCourseDataAndDismiss(CourseBase courseDesign) {
|
||||
|
||||
protected void sendCourseDataAndDismiss(CourseBase courseDesign) {
|
||||
getRaceState().setCourseDesign(MillisecondsTimePoint.now(), courseDesign);
|
||||
saveChangedCourseDesignInCache(courseDesign);
|
||||
dismiss();
|
||||
}
|
||||
saveChangedCourseDesignInCache(courseDesign);
|
||||
dismiss();
|
||||
}
|
||||
|
||||
private void saveChangedCourseDesignInCache(CourseBase courseDesign) {
|
||||
if (!Util.isEmpty(courseDesign.getWaypoints())) {
|
||||
@@ -357,7 +298,6 @@ public class ESSCourseDesignDialog extends RaceDialogFragment {
|
||||
// TODO find a proper name for the highly flexible ESS courses to be shown on the regatta overview page
|
||||
CourseBase design = new CourseDataImpl("Course");
|
||||
List<Waypoint> waypoints = new ArrayList<Waypoint>();
|
||||
|
||||
for (CourseListDataElement courseElement : courseElements) {
|
||||
if ((courseElement.getPassingInstructions().equals(PassingInstruction.Gate)
|
||||
|| courseElement.getPassingInstructions().equals(PassingInstruction.Line) || courseElement
|
||||
@@ -368,7 +308,7 @@ public class ESSCourseDesignDialog extends RaceDialogFragment {
|
||||
ControlPointWithTwoMarks cpwtm = new ControlPointWithTwoMarksImpl(courseElement.getLeftMark(),
|
||||
courseElement.getRightMark(), cpwtmName);
|
||||
Waypoint waypoint = new WaypointImpl(cpwtm, courseElement.getPassingInstructions());
|
||||
|
||||
|
||||
waypoints.add(waypoint);
|
||||
} else {
|
||||
throw new IllegalStateException("Missing second mark");
|
||||
@@ -378,7 +318,7 @@ public class ESSCourseDesignDialog extends RaceDialogFragment {
|
||||
} else {
|
||||
Waypoint waypoint = new WaypointImpl(courseElement.getLeftMark(),
|
||||
courseElement.getPassingInstructions());
|
||||
|
||||
|
||||
waypoints.add(waypoint);
|
||||
}
|
||||
|
||||
@@ -400,7 +340,6 @@ public class ESSCourseDesignDialog extends RaceDialogFragment {
|
||||
builder.setTitle(getString(R.string.use_previous_course_dialog_title));
|
||||
builder.setMessage(getString(R.string.use_previous_course_dialog_message));
|
||||
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
copyPreviousToNewCourseDesign();
|
||||
@@ -471,7 +410,6 @@ public class ESSCourseDesignDialog extends RaceDialogFragment {
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
|
||||
protected void onPassingInstructionPicked(CourseListDataElement courseElement, PassingInstruction pickedDirection) {
|
||||
courseElement.setPassingInstructions(pickedDirection);
|
||||
if (!courseElements.contains(courseElement)) {
|
||||
|
||||
Reference in new issue
Block a user