Search in sources :

Example 6 with Trip

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;
}
Also used : Trip(org.hwyl.sexytopo.model.survey.Trip) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) Date(java.util.Date) JSONObject(org.json.JSONObject) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat)

Example 7 with 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();
}
Also used : Trip(org.hwyl.sexytopo.model.survey.Trip) TextView(android.widget.TextView) Date(java.util.Date)

Example 8 with Trip

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);
}
Also used : EditText(android.widget.EditText) Trip(org.hwyl.sexytopo.model.survey.Trip)

Example 9 with Trip

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;
}
Also used : Survey(org.hwyl.sexytopo.model.survey.Survey) Trip(org.hwyl.sexytopo.model.survey.Trip) ArrayList(java.util.ArrayList) Leg(org.hwyl.sexytopo.model.survey.Leg)

Aggregations

Trip (org.hwyl.sexytopo.model.survey.Trip)9 Date (java.util.Date)3 JSONArray (org.json.JSONArray)3 JSONObject (org.json.JSONObject)3 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 Station (org.hwyl.sexytopo.model.survey.Station)2 EditText (android.widget.EditText)1 TextView (android.widget.TextView)1 ParseException (java.text.ParseException)1 GraphToListTranslator (org.hwyl.sexytopo.control.util.GraphToListTranslator)1 Leg (org.hwyl.sexytopo.model.survey.Leg)1 Survey (org.hwyl.sexytopo.model.survey.Survey)1 JSONException (org.json.JSONException)1