@Override protected String doInBackground(Void... params) { try { final String url = getString(R.string.base_uri) + Constants.initnewrace; // 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("racename", racename); requestData.add("useridstring", ""); // 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 the state from the ResponseEntity return responseEntity.getBody(); } catch (Exception e) { // Log.e(TAG, e.getMessage(), e); } return null; }
@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; }
@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(); }