use of fr.free.nrw.commons.location.LatLng in project apps-android-commons by commons-app.
the class NearbyListFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
// Check that this is the first time view is created,
// to avoid double list when screen orientation changed
Bundle bundle = this.getArguments();
Gson gson = new GsonBuilder().registerTypeAdapter(Uri.class, new UriDeserializer()).create();
if (bundle != null) {
String gsonPlaceList = bundle.getString("PlaceList");
String gsonLatLng = bundle.getString("CurLatLng");
Type listType = new TypeToken<List<Place>>() {
}.getType();
placeList = gson.fromJson(gsonPlaceList, listType);
Type curLatLngType = new TypeToken<LatLng>() {
}.getType();
LatLng curLatLng = gson.fromJson(gsonLatLng, curLatLngType);
placeList = NearbyController.loadAttractionsFromLocationToPlaces(curLatLng, placeList);
}
if (savedInstanceState == null) {
adapter.clear();
Timber.d("Saved instance state is null, populating ListView");
}
adapter.clear();
adapter.addAll(placeList);
adapter.notifyDataSetChanged();
}
use of fr.free.nrw.commons.location.LatLng in project apps-android-commons by commons-app.
the class MediaDataExtractor method getCoordinates.
/**
* Extracts the coordinates from the template and returns them as pretty formatted string.
* Loops over the children of the coordinate template:
* {{Location|47.50111007666667|19.055700301944444}}
* and extracts the latitude and longitude as a pretty string.
*
* @param parentNode The node of the coordinates template.
* @return Pretty formatted coordinates.
* @throws IOException Parsing failed.
*/
private String getCoordinates(Node parentNode) throws IOException {
NodeList childNodes = parentNode.getChildNodes();
double latitudeText = Double.parseDouble(childNodes.item(1).getTextContent());
double longitudeText = Double.parseDouble(childNodes.item(2).getTextContent());
LatLng coordinates = new LatLng(latitudeText, longitudeText, 0);
return coordinates.getPrettyCoordinateString();
}
Aggregations