15 |
|
|
16 |
List<StationBean> stations = new ArrayList<StationBean>(); |
List<StationBean> stations = new ArrayList<StationBean>(); |
17 |
|
|
18 |
|
public boolean lookupStationsByName(String name) { |
19 |
|
return false; // Not supported |
20 |
|
} |
21 |
|
|
22 |
|
@Override |
23 |
|
public boolean lookupStationsByIds(String ids) { |
24 |
|
return false; |
25 |
|
} |
26 |
|
|
27 |
@Override |
@Override |
28 |
public void lookupStations(Location location) { |
public boolean lookupStations(Location location) { |
29 |
|
boolean success = false; |
30 |
//ToDo: to be nice put the api key into the request |
//ToDo: to be nice put the api key into the request |
31 |
String urlSource = "http://www.google.com/uds/GlocalSearch?callback=google.search.LocalSearch.RawCompletion&context=1&q=Train%20station&near=" + location.getLatitude() + "%2C" + location.getLongitude() + "&v=1.0"; |
String urlSource = "http://www.google.com/uds/GlocalSearch?callback=google.search.LocalSearch.RawCompletion&context=1&q=Train%20station&near=" + location.getLatitude() + "%2C" + location.getLongitude() + "&v=1.0"; |
32 |
//String urlSource = "http://www.google.com/uds/GlocalSearch?callback=google.search.LocalSearch.RawCompletion&context=1&q=Train%20station&near=56.2%2C9.0&v=1.0"; |
//String urlSource = "http://www.google.com/uds/GlocalSearch?callback=google.search.LocalSearch.RawCompletion&context=1&q=Train%20station&near=56.2%2C9.0&v=1.0"; |
33 |
|
|
34 |
try { |
try { |
35 |
String data = DownloadUtil.getContent(urlSource, 30000, "UTF-8"); |
String data = DownloadUtil.getContentString(urlSource, 30000); |
36 |
StringBuilder builder = new StringBuilder(data); |
StringBuilder builder = new StringBuilder(data); |
37 |
|
|
38 |
while (builder.charAt(0) != '{') |
while (builder.charAt(0) != '{') |
64 |
Log.e("Location", title + " " + lat +"," + lng); |
Log.e("Location", title + " " + lat +"," + lng); |
65 |
} |
} |
66 |
|
|
67 |
|
success = true; |
68 |
} catch (Exception e) { |
} catch (Exception e) { |
69 |
Log.e("Location","Location",e); |
Log.e("Location","Location",e); |
70 |
} |
} |
71 |
|
return success; |
72 |
} |
} |
73 |
|
|
74 |
@Override |
@Override |