@Override public int hashCode() { int result = status != null ? status.hashCode() : 0; result = 31 * result + (results != null ? results.hashCode() : 0); return result; }
public String value() { return name(); }
public static GeocoderStatus fromValue(String v) { return valueOf(v); }
@Override protected FilterResults performFiltering(CharSequence constraint) { FilterResults fr = new FilterResults(); if (constraint != null && constraint.length() > 5) { GeocoderRequest geocoderRequest = new GeocoderRequestBuilder().setAddress(constraint.toString()) .setLanguage("fr").setBounds(TransportsRennesApplication.getBounds()).getGeocoderRequest(); GeocodeResponse reponseResult = null; Log.d("YBO", geocoderRequest.toString()); try { reponseResult = TransportsRennesApplication.getGeocodeUtil().geocode(geocoderRequest); } catch (Exception ignore) { } List<String> results = new ArrayList<String>(); String upper = StringOperation.sansAccents(constraint.toString().toUpperCase()); for (Arret arret : arrets) { if (arret.nom.contains(upper)) { results.add(arret.nom); } } if (reponseResult != null && reponseResult.getStatus().equals(GeocoderStatus.OK)) { for (GeocoderResult oneResult : reponseResult.getResults()) { results.add(oneResult.getFormattedAddress()); } } fr.values = results; fr.count = results.size(); } return fr; }
@Override public synchronized Coordinates getCoordinates(final String address) throws GeocoderException { ensureInitialized(); final GeocoderRequest request = new GeocoderRequestBuilder().setAddress(address).setLanguage("en").getGeocoderRequest(); GeocodeResponse response; try { response = m_geocoder.geocode(request); } catch (IOException e) { // Makes the assumption that IO related exceptions are temporary, which is suitable for most scenarios throw new TemporaryGeocoderException("Failed to get coordinates for " + address + " using the Google Geocoder.", e); } switch (response.getStatus()) { case OK: return new GoogleCoordinates(response.getResults().get(0)); case OVER_QUERY_LIMIT: throw new TemporaryGeocoderException("Failed to get coordinates for " + address + " using the Google Geocoder. You have exceeded the daily usage limit."); case ERROR: case INVALID_REQUEST: case REQUEST_DENIED: case UNKNOWN_ERROR: case ZERO_RESULTS: default: throw new GeocoderException("Failed to get coordinates for " + address + " using Google Geocoder. Response was: " + response.getStatus().toString()); } } }
if (reponseResult != null && reponseResult.getStatus().equals(GeocoderStatus.OK)) { for (GeocoderResult oneResult : reponseResult.getResults()) { results.add(oneResult.getFormattedAddress());