56 |
|
|
57 |
String name = launchedBy.getStringExtra("name"); |
String name = launchedBy.getStringExtra("name"); |
58 |
((TextView) findViewById(R.id.stationName)).setText( name ); |
((TextView) findViewById(R.id.stationName)).setText( name ); |
59 |
|
|
60 |
((TextView) findViewById(R.id.stationAddr)).setText( "searching..." ); |
String address = launchedBy.getStringExtra("address"); |
61 |
|
((TextView) findViewById(R.id.stationAddr)).setText( address ); |
62 |
|
|
63 |
int stationId = launchedBy.getIntExtra("stationid", -1); |
int stationId = launchedBy.getIntExtra("stationid", -1); |
64 |
|
|
157 |
return super.onCreateDialog(id); |
return super.onCreateDialog(id); |
158 |
} |
} |
159 |
} |
} |
|
|
|
|
String lookupAddress(double latitude, double longitude) { |
|
|
|
|
|
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(); |
|
|
} |
|
160 |
|
|
161 |
class DialogDismisser implements View.OnClickListener { |
class DialogDismisser implements View.OnClickListener { |
162 |
|
|
191 |
adapter.setDepartures(departures); |
adapter.setDepartures(departures); |
192 |
pgDialog.dismiss(); |
pgDialog.dismiss(); |
193 |
|
|
|
|
|
|
((TextView) findViewById(R.id.stationAddr)).setText( addr ); |
|
|
|
|
194 |
if (departures.size() == 0) |
if (departures.size() == 0) |
195 |
MessageBox.showMessage(DepartureList.this, "No departures found"); |
MessageBox.showMessage(DepartureList.this, "No departures found"); |
196 |
} |
} |
197 |
|
|
198 |
@Override |
@Override |
199 |
protected Void doInBackground(Integer... params) { |
protected Void doInBackground(Integer... params) { |
|
addr = lookupAddress( latitude , longitude); |
|
200 |
provider.lookupDepartures(params[0]); |
provider.lookupDepartures(params[0]); |
201 |
departures = provider.getDepartures(); |
departures = provider.getDepartures(); |
202 |
return null; |
return null; |