use constants for exception message construction and matching

Change-Id: I3df736af045d46f1f39dbc0a36a9c0824122b6a8
This commit is contained in:
Axel Uhl committed 2016-04-18 23:44:51 +02:00
1 parent f1fedb1d0e
commit f00e91075f
1 file changed
+6 -4
@@ -55,6 +55,8 @@ import com.sap.sse.common.impl.MillisecondsTimePoint;
public class CourseFragmentMarks extends CourseFragment implements CourseMarkAdapter.MarkClick, CourseElementAdapter.EventListener, CourseElementAdapter.ItemClick {
private static final String EACH_WAYPOINT_NEEDS_PASSING_INSTRUCTIONS = "Each waypoint needs passing instructions";
private static final String MISSING_SECOND_MARK = "Missing second mark";
private ReadonlyDataManager mDataManager;
private RecyclerViewDragDropManager mDragDropManager;
private RecyclerViewSwipeManager mSwipeManager;
@@ -240,10 +242,10 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
}
sendCourseDataAndDismiss(courseData);
} catch (IllegalStateException ex) {
if (ex.getMessage().equals("Missing second mark")) {
if (ex.getMessage().equals(MISSING_SECOND_MARK)) {
String toastText = getString(R.string.error_missing_second_mark);
Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show();
} else if (ex.getMessage().equals("Each waypoint needs passing instructions")) {
} else if (ex.getMessage().equals(EACH_WAYPOINT_NEEDS_PASSING_INSTRUCTIONS)) {
String toastText = getString(R.string.error_missing_passing_instructions);
Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show();
}
@@ -531,10 +533,10 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
waypoints.add(waypoint);
} else {
throw new IllegalStateException("Missing second mark");
throw new IllegalStateException(MISSING_SECOND_MARK);
}
} else if (courseElement.getPassingInstructions().equals(PassingInstruction.None)) {
throw new IllegalStateException("Each waypoints needs passing instructions");
throw new IllegalStateException(EACH_WAYPOINT_NEEDS_PASSING_INSTRUCTIONS);
} else {
Waypoint waypoint = new WaypointImpl(courseElement.getLeftMark(), courseElement.getPassingInstructions());