diff --git a/gen/.gitignore b/gen/.gitignore index d11eccb..0b07fd2 100644 --- a/gen/.gitignore +++ b/gen/.gitignore @@ -1,4 +1,4 @@ -/it -/.gitignore /android /com +/it +/.gitignore diff --git a/src/it/unisa/followteam/MappaPercorso.java b/src/it/unisa/followteam/MappaPercorso.java index 0409695..3ab486a 100644 --- a/src/it/unisa/followteam/MappaPercorso.java +++ b/src/it/unisa/followteam/MappaPercorso.java @@ -30,6 +30,7 @@ import android.provider.Settings; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -204,74 +205,72 @@ public void onClick(DialogInterface dialog, int which) { public void onPause() { super.onPause(); } - + private class ReadTask extends AsyncTask { - @Override - protected String doInBackground(String... url) { - String data = ""; - try { - HttpConnection http = new HttpConnection(); - data = http.readUrl(url[0]); - } catch (Exception e) { - } - return data; - } - - @Override - protected void onPostExecute(String result) { - super.onPostExecute(result); - new ParserTask().execute(result); - } - - private class ParserTask extends - AsyncTask>>> { - - @Override - protected List>> doInBackground( - String... jsonData) { - - JSONObject jObject; - List>> routes = null; - - try { - jObject = new JSONObject(jsonData[0]); - PathJSONParser parser = new PathJSONParser(); - routes = parser.parse(jObject); - } catch (Exception e) { - e.printStackTrace(); - } - return routes; - } - - @Override - protected void onPostExecute( - List>> routes) { - ArrayList points = null; - PolylineOptions polyLineOptions = null; - - // traversing through routes - for (int i = 0; i < routes.size(); i++) { - points = new ArrayList(); - polyLineOptions = new PolylineOptions(); - List> path = routes.get(i); - - for (int j = 0; j < path.size(); j++) { - HashMap point = path.get(j); - - double lat = Double.parseDouble(point.get("lat")); - double lng = Double.parseDouble(point.get("lng")); - LatLng position = new LatLng(lat, lng); - - points.add(position); - } - - polyLineOptions.addAll(points); - polyLineOptions.width(2); - polyLineOptions.color(Color.BLUE); - } - - map.addPolyline(polyLineOptions); - } - } - } + @Override + protected String doInBackground(String... url) { + String data = ""; + try { + HttpConnection http = new HttpConnection(); + data = http.readUrl(url[0]); + } catch (Exception e) { + } + return data; + } + + @Override + protected void onPostExecute(String result) { + super.onPostExecute(result); + new ParserTask().execute(result); + } + } + + private class ParserTask extends + AsyncTask>>> { + + @Override + protected List>> doInBackground( + String... jsonData) { + + JSONObject jObject; + List>> routes = null; + + try { + jObject = new JSONObject(jsonData[0]); + PathJSONParser parser = new PathJSONParser(); + routes = parser.parse(jObject); + } catch (Exception e) { + e.printStackTrace(); + } + return routes; + } + + @Override + protected void onPostExecute(List>> routes) { + ArrayList points = null; + PolylineOptions polyLineOptions = null; + + // traversing through routes + for (int i = 0; i < routes.size(); i++) { + points = new ArrayList(); + polyLineOptions = new PolylineOptions(); + List> path = routes.get(i); + + for (int j = 0; j < path.size(); j++) { + HashMap point = path.get(j); + + double lat = Double.parseDouble(point.get("lat")); + double lng = Double.parseDouble(point.get("lng")); + LatLng position = new LatLng(lat, lng); + + points.add(position); + } + + polyLineOptions.addAll(points); + polyLineOptions.width(10); + polyLineOptions.color(Color.RED); + } + map.addPolyline(polyLineOptions); + } + } }