コード例 #1
0
 public void OnLocationUpdate(Location loc) {
   System.out.println("LOCATION UPDATE IN RACEACTIVITYYYYY!!!!!");
   Utilities.LogDebug("LOCATION UPDATE IN RACEACTIVITYYYYY!!!!!");
   // send location to webserver
   raceState.sendUpdate(raceId, loc.getLongitude(), loc.getLatitude(), loc.getAltitude());
   // retrieve update from webserver
   raceState.receiveUpdate();
 }
コード例 #2
0
 private void StartAndBindService() {
   Utilities.LogDebug("StartAndBindService FROM RACEACTIVITY - binding now");
   serviceIntent = new Intent(this, GpsLoggingService.class);
   // Start the service in case it isn't already running
   startService(serviceIntent);
   // Now bind to service
   bindService(serviceIntent, gpsServiceConnection, Context.BIND_AUTO_CREATE);
   Session.setRaceBoundToService(true);
 }
コード例 #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_race_main);
    //        getActionBar().setDisplayHomeAsUpEnabled(true);

    // default settings
    Utilities.PopulateAppSettings(getApplicationContext());
    // get Extras

    Intent intent = getIntent();
    isAlone = intent.getBooleanExtra("alone", false);
    raceId = intent.getIntExtra("raceid", IDNOTSET);
    selectedUsers = intent.getParcelableArrayListExtra("users");

    // init state
    if (isAlone) {
      raceState = new AloneRace();
    } else {
      raceState = new WithFriendsRace();
    }

    // set preferences:
    SharedPreferences prefs =
        PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    Editor editor = prefs.edit();
    editor.putString("time_before_logging", "15");

    editor.commit();

    AppSettings.setMinimumSeconds(15);

    // start service if not started and bind
    StartAndBindService();

    // define the order of colors
    colors = new ArrayList<Integer>();
    colors.add(Color.CYAN);
    colors.add(Color.BLUE);
    colors.add(Color.GREEN);
    colors.add(Color.MAGENTA);
    colors.add(Color.RED);

    initDrawings();
    drawCircle();
    refreshPaint();
  }
コード例 #4
0
    @Override
    protected RaceStatisticsListDTO doInBackground(Void... params) {
      try {

        final String url = getString(R.string.base_uri) + Constants.updateracestatus;

        // Set the Accept header for "application/json" or "application/xml"
        HttpHeaders requestHeaders = new HttpHeaders();
        List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
        acceptableMediaTypes.add(MediaType.APPLICATION_XML);
        requestHeaders.setAccept(acceptableMediaTypes);

        String username = AppSettings.getServer_username();
        String password = AppSettings.getServer_password();

        MultiValueMap<String, String> requestData = new LinkedMultiValueMap<String, String>();
        requestData.add("username", username);
        requestData.add("password", password);
        requestData.add("raceid", "" + raceId);

        // Populate the headers in an HttpEntity object to use for the request
        HttpEntity<MultiValueMap<String, String>> requestEntity =
            new HttpEntity<MultiValueMap<String, String>>(requestData, requestHeaders);

        // Create a new RestTemplate instance
        RestTemplate restTemplate = new RestTemplate();

        // Perform the HTTP GET request
        ResponseEntity<RaceStatisticsListDTO> responseEntity =
            restTemplate.exchange(url, HttpMethod.POST, requestEntity, RaceStatisticsListDTO.class);

        // Return the state from the ResponseEntity
        RaceStatisticsListDTO liste = responseEntity.getBody();
        return liste;

      } catch (Exception e) {
        Utilities.LogError("receiveUpdate", e);
      }

      return null;
    }
コード例 #5
0
    @Override
    protected String doInBackground(Void... params) {
      try {

        final String url = getString(R.string.base_uri) + Constants.addracelocation;

        // Set the Accept header for "application/json" or "application/xml"
        HttpHeaders requestHeaders = new HttpHeaders();
        List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
        acceptableMediaTypes.add(MediaType.MULTIPART_FORM_DATA);
        requestHeaders.setAccept(acceptableMediaTypes);

        String username = AppSettings.getServer_username();
        String password = AppSettings.getServer_password();

        MultiValueMap<String, String> requestData = new LinkedMultiValueMap<String, String>();
        requestData.add("username", username);
        requestData.add("password", password);
        requestData.add("raceid", "" + raceId);
        requestData.add("longitude", "" + longitude);
        requestData.add("latitude", "" + latitude);
        requestData.add("altitude", "" + altitude);
        // Populate the headers in an HttpEntity object to use for the request
        HttpEntity<MultiValueMap<String, String>> requestEntity =
            new HttpEntity<MultiValueMap<String, String>>(requestData, requestHeaders);

        // Create a new RestTemplate instance
        RestTemplate restTemplate = new RestTemplate();

        // Perform the HTTP GET request
        ResponseEntity<String> responseEntity =
            restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);

        return responseEntity.getBody();

      } catch (Exception e) {
        Utilities.LogError("sending location infos", e);
      }

      return null;
    }