protected void advanceToNextScreen(final GeocodedAddress g) { Assert.assertNotNull(g); try { final Country nat = this.bundleCreatedWith.getParcelable(EXTRAS_COUNTRY_ID); DBManager.addZipCode(SDPostcodeUK_BS7666.this, g.getPostalCode(), nat.COUNTRYCODE); } catch (final DataBaseException e) { // Log.e(DEBUGTAG, "Error on inserting Postcode", e); } final int mode = SDPostcodeUK_BS7666.this.bundleCreatedWith.getInt(MODE_SD); switch (mode) { case MODE_SD_DESTINATION: /* Add the StreetNumber to the Bundle to be passed further. */ SDPostcodeUK_BS7666.this.bundleCreatedWith.putInt(EXTRAS_MODE, EXTRAS_MODE_DIRECT_LATLNG); SDPostcodeUK_BS7666.this.bundleCreatedWith.putInt( EXTRAS_DESTINATION_LATITUDE_ID, g.getLatitudeE6()); SDPostcodeUK_BS7666.this.bundleCreatedWith.putInt( EXTRAS_DESTINATION_LONGITUDE_ID, g.getLongitudeE6()); /* Create an Intent to open the Map as a SubActivity. */ final Intent fetchRouteIntent = new Intent(SDPostcodeUK_BS7666.this, OpenStreetDDMap.class); /* Pass the Bundle this Activity was created with further. */ fetchRouteIntent.putExtras(SDPostcodeUK_BS7666.this.bundleCreatedWith); startActivityForResult(fetchRouteIntent, REQUESTCODE_FETCHROUTE); break; case MODE_SD_WAYPOINT: case MODE_SD_SETHOME: case MODE_SD_RESOLVE: final Intent resultData = new Intent(); /* Add the StreetNumber to the Bundle to be passed further. */ SDPostcodeUK_BS7666.this.bundleCreatedWith.putInt(EXTRAS_MODE, EXTRAS_MODE_DIRECT_LATLNG); SDPostcodeUK_BS7666.this.bundleCreatedWith.putInt( EXTRAS_DESTINATION_LATITUDE_ID, g.getLatitudeE6()); SDPostcodeUK_BS7666.this.bundleCreatedWith.putInt( EXTRAS_DESTINATION_LONGITUDE_ID, g.getLongitudeE6()); resultData.putExtras(SDPostcodeUK_BS7666.this.bundleCreatedWith); SDPostcodeUK_BS7666.this.setResult(SUBACTIVITY_RESULTCODE_CHAINCLOSE_SUCCESS, resultData); SDPostcodeUK_BS7666.this.finish(); break; } }
private ArrayList<String> doAutocomplete(final int pos) { final String postcode = SDPostcodeUK_BS7666.this.postcodeEditText_1.getText().toString() + " " + SDPostcodeUK_BS7666.this.postcodeEditText_2.getText().toString(); try { final GeocodedAddress g = new Requester().request(postcode); final ArrayList<String> out = new ArrayList<String>(); final String[] parts = g.getPostalCode().split(" "); if (parts.length > pos && parts[pos] != null) { out.add(parts[pos]); } return out; } catch (final Exception e) { // Log.e(DEBUGTAG, "Geocoding-Error", e); return null; } }