Guest User

Untitled

a guest
Nov 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. @Override
  2. protected void onPostExecute(String result) {
  3. super.onPostExecute(result);
  4. dialogo.dismiss();
  5.  
  6. lista.setAdapter(new MiListaAdapter(cxt, R.layout.item_list, jsonArray, lat1, lon1));
  7. lista.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
  8. }
  9.  
  10. public static double distance(LatLng StartP, LatLng EndP) {
  11. double lat1 = StartP.latitude;
  12. double lat2 = EndP.latitude;
  13. double lon1 = StartP.longitude;
  14. double lon2 = EndP.longitude;
  15. double dLat = Math.toRadians(lat2-lat1);
  16. double dLon = Math.toRadians(lon2-lon1);
  17. double a = Math.sin(dLat/2) * Math.sin(dLat/2) +
  18. Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) *
  19. Math.sin(dLon/2) * Math.sin(dLon/2);
  20. double c = 2 * Math.asin(Math.sqrt(a));
  21. return 6366000 * c;
  22. }
  23.  
  24. Double distance = distance(new LatLng(lat1, lon1),
  25. new LatLng(Double.parseDouble(lat2), Double.parseDouble(lon2)));
  26.  
  27. v.txtDistancia.setText("Distancia: " + distance);
Add Comment
Please, Sign In to add comment