@Test public void getFromLocationReturnsTheOverwrittenListLimitingByMaxResults() throws IOException { ShadowGeocoder shadowGeocoder = shadowOf(geocoder); List<Address> list = Arrays.asList(new Address(Locale.getDefault()), new Address(Locale.CANADA)); shadowGeocoder.setFromLocation(list); List<Address> result = geocoder.getFromLocation(90.0, 90.0, 1); assertThat(result).hasSize(1); result = geocoder.getFromLocation(90.0, 90.0, 2); assertThat(result).hasSize(2); result = geocoder.getFromLocation(90.0, 90.0, 3); assertThat(result).hasSize(2); }
private Address makeAddress() { Address address = new Address(Locale.getDefault()); shadowOf(address).setSimulatedHasLatLong(hasLatitude, hasLongitude); return address; }
JSONObject result = results.getJSONObject(i); Address addr = new Address(Locale.getDefault());
private Address makeAddress() { Address address = new Address(Locale.getDefault()); address.setLatitude(simulatedLatitude); address.setLongitude(simulatedLongitude); ReflectionHelpers.setField(address, "mHasLatitude", hasLatitude); ReflectionHelpers.setField(address, "mHasLongitude", hasLongitude); return address; }
Address gAddress = new Address(mLocale); String displayName = ""; if (!jResult.has("point") || !jResult.has("name"))
return null; Address address = new Address(locale); address.setLatitude(result.getDouble(WIRE_LATITUDE)); address.setLongitude(result.getDouble(WIRE_LONGITUDE));
Address gAddress = new Address(mLocale); if (!jResult.has("lat") || !jResult.has("lon") || !jResult.has("address")) return null;
return lookupAddress(latitude, longitude, false); address = new Address(locale);
public static android.location.Address toAddress(PersistableBundle persistableBundle) { if (persistableBundle == null) { return null; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { String language = persistableBundle.getString("language"); String country = persistableBundle.getString("country"); String variant = persistableBundle.getString("variant"); Locale addressLocale = new Locale(language, country, variant); android.location.Address address = new android.location.Address(addressLocale); address.setLocality(persistableBundle.getString("locality")); address.setSubLocality(persistableBundle.getString("subLocality")); address.setAdminArea(persistableBundle.getString("adminArea")); address.setSubAdminArea(persistableBundle.getString("subAdminArea")); address.setCountryName(persistableBundle.getString("countryName")); return address; } else { return null; } }