207 |
if (loc != null) { |
if (loc != null) { |
208 |
message.append( getString(stationlist_obtainedby) ).append( loc.getProvider() ).append("\n"); |
message.append( getString(stationlist_obtainedby) ).append( loc.getProvider() ).append("\n"); |
209 |
message.append( getString(stationlist_accuracy) ).append( (int)loc.getAccuracy()).append("m\n"); |
message.append( getString(stationlist_accuracy) ).append( (int)loc.getAccuracy()).append("m\n"); |
210 |
message.append( getString(stationlist_latitude) ).append( loc.getLatitude()).append("\n"); |
message.append( getString(stationlist_latitude) ).append( (float)loc.getLatitude()).append("\n"); |
211 |
message.append( getString(stationlist_longitude) ).append( loc.getLongitude() ).append("\n"); |
message.append( getString(stationlist_longitude) ).append( (float)loc.getLongitude() ).append("\n"); |
212 |
} else { |
} else { |
213 |
message.append( getString(stationlist_nolocation) ); |
message.append( getString(stationlist_nolocation) ); |
214 |
} |
} |
334 |
showDialog(DLG_PROGRESS); |
showDialog(DLG_PROGRESS); |
335 |
|
|
336 |
findStationsTask = new FindStationsTask(); |
findStationsTask = new FindStationsTask(); |
337 |
findStationsTask.searchByName(name, locationLookup.getLocation()); |
findStationsTask.searchByName(name); |
338 |
findStationsTask.execute(); |
findStationsTask.execute(); |
339 |
|
|
340 |
} |
} |
346 |
showDialog(DLG_PROGRESS); |
showDialog(DLG_PROGRESS); |
347 |
|
|
348 |
findStationsTask = new FindStationsTask(); |
findStationsTask = new FindStationsTask(); |
349 |
findStationsTask.searchByIds(favorites.toString(), locationLookup.getLocation()); |
findStationsTask.searchByIds( favorites.toString() ); |
350 |
findStationsTask.execute(); |
findStationsTask.execute(); |
351 |
} else { |
} else { |
352 |
showMessageAndClose( getString( stationlist_nofavorites ) ); |
showMessageAndClose( getString( stationlist_nofavorites ) ); |
364 |
findStationsTask.searchByLocation( locationLookup.getLocation() ); |
findStationsTask.searchByLocation( locationLookup.getLocation() ); |
365 |
findStationsTask.execute(); |
findStationsTask.execute(); |
366 |
} |
} |
|
|
|
|
|
|
|
/* TODO: Remove this no longer needed function |
|
|
String lookupAddress(double latitude, double longitude) { |
|
367 |
|
|
|
Geocoder coder = new Geocoder(this, new Locale("da")); |
|
|
StringBuilder sb = new StringBuilder(); |
|
|
Log.i("lookupaddr", "" + latitude + "/" + longitude); |
|
|
try { |
|
|
List<Address> addressList = coder.getFromLocation(latitude, longitude, 1); |
|
|
Address addr = addressList.get(0); |
|
|
|
|
|
|
|
|
int max = addr.getMaxAddressLineIndex(); |
|
|
for (int i=0; i<max; i++) { |
|
|
if (i>0) |
|
|
sb.append(", "); |
|
|
|
|
|
sb.append(addr.getAddressLine(i)); |
|
|
} |
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
Log.e("DepartureList", "geocoder failed", e); |
|
|
} |
|
|
|
|
|
return sb.toString(); |
|
|
}*/ |
|
|
|
|
368 |
|
|
369 |
//////////////////////////////////////////////////////////////////////////// |
//////////////////////////////////////////////////////////////////////////// |
370 |
// Inner classes |
// Inner classes |
428 |
Location loc; |
Location loc; |
429 |
String ids; |
String ids; |
430 |
|
|
431 |
public void searchByName(String n, Location l) { |
public void searchByName(String n) { |
432 |
|
|
433 |
method = LookupMethod.ByName; |
method = LookupMethod.ByName; |
|
loc = l; |
|
434 |
name = n; |
name = n; |
435 |
} |
} |
436 |
|
|
439 |
loc = l; |
loc = l; |
440 |
} |
} |
441 |
|
|
442 |
public void searchByIds(String id, Location l) { |
public void searchByIds(String id) { |
443 |
|
|
444 |
method = LookupMethod.ByList; |
method = LookupMethod.ByList; |
|
loc = l; |
|
445 |
ids = id; |
ids = id; |
446 |
} |
} |
447 |
|
|
471 |
} |
} |
472 |
|
|
473 |
|
|
|
Location dummy = new Location("gps"); |
|
|
List<StationBean> stations = stationProvider.getStations(); |
|
|
|
|
|
for (StationBean station : stations) { |
|
|
|
|
|
if (method.equals(LookupMethod.ByName) || method.equals(LookupMethod.ByList)) { |
|
|
if (loc != null) { //only do the distance calc if we have a location |
|
|
dummy.setLatitude(station.getLatitude()); |
|
|
dummy.setLongitude(station.getLongitude()); |
|
|
station.setDistance( (int)loc.distanceTo(dummy) ); |
|
|
} else { |
|
|
station.setDistance(0); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
474 |
return null; |
return null; |
475 |
} |
} |
476 |
|
|
481 |
|
|
482 |
|
|
483 |
if (success) { |
if (success) { |
484 |
if (stationProvider.getStations().size() == 0) |
if (stationProvider.getStations().size() == 0) { |
485 |
MessageBox.showMessage(StationList.this, getString(stationlist_nostations) ); // this should not be possible !?! |
showMessageAndClose(getString(stationlist_nostations)); |
486 |
|
} |
487 |
stations = stationProvider.getStations(); |
stations = stationProvider.getStations(); |
488 |
adapter.setStations( stations ); |
adapter.setStations( stations ); |
489 |
|
|