--- android/TrainInfo/src/dk/thoerup/traininfo/TrainInfoList.java 2009/08/10 19:37:18 258 +++ android/TrainInfo/src/dk/thoerup/traininfo/TrainInfoList.java 2009/09/11 08:48:18 316 @@ -2,16 +2,19 @@ import java.util.ArrayList; import java.util.List; +import java.util.Locale; import android.app.Dialog; import android.app.ListActivity; import android.app.ProgressDialog; import android.content.Intent; +import android.location.Address; +import android.location.Geocoder; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Message; - +import android.util.Log; import android.view.View; import android.widget.ListView; import dk.thoerup.traininfo.util.MessageBox; @@ -52,7 +55,7 @@ startLookup(); } else { stations = (ArrayList) savedInstanceState.getSerializable("stations"); - adapter.setStations(new ArrayList(stations)); + adapter.setStations(stations); } } @@ -124,7 +127,12 @@ dialog.dismiss(); if (isRunning) { locator.abortLocationListener(); - MessageBox.showMessage(TrainInfoList.this,"GPS fix timed out"); + if (locator.hasLocation()) { + msg.what = GOTLOCATION; + handleMessage( msg ); // ToDo: ugly recursive call !!! + } else { + MessageBox.showMessage(TrainInfoList.this,"GPS fix timed out"); + } } break; case LOOKUPSTATIONFAILED: @@ -141,21 +149,25 @@ @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); - - + StationBean station = stations.get(position); - + + double latitude = station.getLatitude(); + double longitude = station.getLongitude(); + + Intent intent = new Intent(this, DepartureList.class); intent.putExtra("name", station.getName()); - intent.putExtra("address", station.getAddress()); intent.putExtra("distance", station.getDistance()); - intent.putExtra("latitude", station.getLatitude()); - intent.putExtra("longitude", station.getLongitude()); + intent.putExtra("latitude", latitude); + intent.putExtra("longitude", longitude); + intent.putExtra("stationid", station.getId()); startActivity(intent); } + class LocatorTask extends AsyncTask { @Override protected void onPreExecute() {