--- android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/06/13 13:45:37 843 +++ android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/07/02 14:58:44 948 @@ -48,13 +48,14 @@ public static final int OPTIONS_MAP = 2003; public static final int OPTIONS_GPSINFO = 2004; - - - public static final int DLG_PROGRESS = 3001; public static final int DLG_STATIONNAME = 3002; + + public static final int GPS_TIMEOUT_MS = 17500; //how long are we willing to wait for gps fix -in milliseconds + + static enum LookupMethod { ByLocation, ByName, @@ -139,6 +140,22 @@ } } + + + @Override + protected void onDestroy() { + super.onDestroy(); + + if (findStationsTask != null) { + findStationsTask.cancel(true); + } + if (locationLookup != null) { + locationLookup.stopSearch(); + } + isRunning = false; + } + + protected void setTitle() { String dialogTitle = getResources().getString(app_name); switch (listType) { @@ -258,7 +275,7 @@ message.append( getString(stationlist_nolocation) ); } - MessageBox.showMessage(this, message.toString()); + MessageBox.showMessage(this, message.toString(), false); break; default: retval = super.onOptionsItemSelected(item); @@ -379,7 +396,7 @@ showDialogSafe(DLG_PROGRESS); locationLookup.locateStations(); - stationsFetched.sendEmptyMessageDelayed(LOCATIONFIXTIMEOUT, 20000); + stationsFetched.sendEmptyMessageDelayed(LOCATIONFIXTIMEOUT, GPS_TIMEOUT_MS); } void startNameSearch(String name) { @@ -437,7 +454,8 @@ case NOPROVIDER: dismissDialogSafe(DLG_PROGRESS); - MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider) ); + MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider), true ); + //StationList.this.finish(); break; case LOCATIONFIXTIMEOUT: if (isRunning) { @@ -538,11 +556,14 @@ showMessageAndClose(getString(stationlist_nostations)); } stations = stationProvider.getStations(); + + StationList.this.getListView().invalidateViews(); adapter.setStations( stations ); + } else { //communication or parse errors AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this); - builder.setMessage(getString(stationlist_nearbyerror)); + builder.setMessage(getString(stationlist_fetcherror)); builder.setCancelable(true); builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) {