--- android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/02/02 08:52:45 579 +++ android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/04/20 14:17:34 652 @@ -18,6 +18,7 @@ import android.os.Handler; import android.os.Message; +import android.util.Log; import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.Menu; @@ -495,20 +496,47 @@ public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); - stationsFetched.post( new Runnable() { - @Override - public void run() { - startLocatorTask(); - } - }); + Runnable runner = null; + switch (method) { + case ByLocation: + runner = new Runnable() { + @Override + public void run() { + startLocatorTask(); + } + }; + break; + case ByName: + runner = new Runnable() { + @Override + public void run() { + startNameSearch( FindStationsTask.this.name ); + } + }; + break; + case ByList: + runner = new Runnable() { + @Override + public void run() { + startFavoriteLookup(); + } + }; + break; + } + + stationsFetched.post( runner ); } }); builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } - }); - builder.show(); + }); + try { + builder.show(); + } catch (android.view.WindowManager.BadTokenException e) { + Log.i("StationList", "BadTokenException"); // this can happen if the user switched away from this activity, while doInBackground was running + } } } }