use of org.hwyl.sexytopo.model.survey.Trip in project sexytopo by richsmith.
the class SurveyJsonTranslater method toTrip.
public static Trip toTrip(JSONObject json) throws JSONException, ParseException {
DateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
String dateString = json.getString(TRIP_DATE_TAG);
Date date = dateFormat.parse(dateString);
json.put(TRIP_DATE_TAG, date);
String comments = json.getString(COMMENT_TAG);
JSONArray teamArray = json.getJSONArray(TEAM_TAG);
List<Trip.TeamEntry> team = new ArrayList<>();
for (JSONObject teamEntryJson : Util.toList(teamArray)) {
String name = teamEntryJson.getString(TEAM_MEMBER_NAME_TAG);
JSONArray rolesArray = teamEntryJson.getJSONArray(TEAM_MEMBER_ROLE_TAG);
List<Trip.Role> roles = new ArrayList<>();
for (String roleString : Util.toListOfStrings(rolesArray)) {
Trip.Role role = Trip.Role.valueOf(roleString);
roles.add(role);
}
Trip.TeamEntry teamEntry = new Trip.TeamEntry(name, roles);
team.add(teamEntry);
}
Trip trip = new Trip();
trip.setDate(date);
trip.setTeam(team);
trip.setComments(comments);
return trip;
}
use of org.hwyl.sexytopo.model.survey.Trip in project sexytopo by richsmith.
the class TripActivity method onResume.
@Override
protected void onResume() {
super.onResume();
Trip trip = getSurvey().getTrip();
if (trip == null) {
trip = new Trip();
}
team = new ArrayList<>(trip.getTeam());
String comments = trip.getComments();
TextView commentsField = findViewById(R.id.trip_comments);
commentsField.setText(comments);
Date date = trip.getDate();
String formatted = DATE_FORMAT.format(date);
TextView dateField = findViewById(R.id.trip_date);
dateField.setText(getText(R.string.trip) + " " + formatted + ". " + getText(R.string.team) + ":");
syncListWithTeam();
updateButtonStatus();
}
use of org.hwyl.sexytopo.model.survey.Trip in project sexytopo by richsmith.
the class TripActivity method requestSaveTrip.
public void requestSaveTrip(View view) {
EditText commentsField = findViewById(R.id.trip_comments);
String comments = commentsField.getText().toString();
Trip trip = getSurvey().getTrip();
if (trip == null) {
trip = new Trip();
}
trip.setTeam(team);
trip.setComments(comments);
getSurvey().setTrip(trip);
startActivity(PlanActivity.class);
}
use of org.hwyl.sexytopo.model.survey.Trip in project sexytopo by richsmith.
the class BasicTestSurveyCreator method createStraightNorthWithTrip.
@SuppressWarnings("ArraysAsListWithZeroOrOneArgument")
public static Survey createStraightNorthWithTrip() {
Survey survey = new Survey("Test Straight Survey North");
List<Trip.TeamEntry> team = new ArrayList<>();
team.add(new Trip.TeamEntry("Alice", Arrays.asList(Trip.Role.BOOK)));
team.add(new Trip.TeamEntry("Bob", Arrays.asList(Trip.Role.INSTRUMENTS, Trip.Role.DOG)));
Trip trip = new Trip();
trip.setTeam(team);
survey.setTrip(trip);
Leg leg0 = new Leg(5, 0, 0);
SurveyUpdater.updateWithNewStation(survey, leg0);
Leg leg1 = new Leg(5, 0, 0);
SurveyUpdater.updateWithNewStation(survey, leg1);
Leg leg2 = new Leg(5, 0, 0);
SurveyUpdater.updateWithNewStation(survey, leg2);
return survey;
}
Aggregations