--- android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/08/03 06:12:10 1007 +++ android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/08/03 06:36:29 1008 @@ -123,7 +123,7 @@ startLookup(); break; case ListSearch: - showDialog(DLG_STATIONNAME); //TODO: this.showDialogSafe(DLG_STATIONNAME); + showDialog(DLG_STATIONNAME); break; case ListFavorites: startFavoriteLookup(); @@ -175,49 +175,7 @@ } - - /* these 3 dialogs helper functions are very rude and ugly hack - * to remove these auto-reported exceptions - * - android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@436aaef8 is not valid; is your activity running? - * - java.lang.IllegalArgumentException: View not attached to window manager - */ - - /* - public void showDialogSafe(int id) { - try { - showDialog(id); - } catch (Exception e) { - Log.e("StationList", "showDialog failed", e); - } - } - - public void dismissDialogSafe(int id) { - try { - dismissDialog(id); - } catch (Exception e) { - Log.e("StationList", "dismissDialog failed", e); - } - } - public void dismissDialogSafe(Dialog dlg) { - try { - dlg.dismiss(); - } catch (Exception e) { - Log.e("StationList", "dismissDialog failed", e); - } - } - - public void builderShowSafe(AlertDialog.Builder builder) { - try { - builder.show(); - } catch (Exception e) { - Log.e("StationList", "builder.show() failed", e); - } - }*/ - - /* EOF rude and ugly dialog hack */ - - @Override public void onSaveInstanceState(Bundle outState) @@ -394,7 +352,7 @@ public void startLookup() { isRunning = true; dialogMessage = getString( stationlist_waitforlocation ); - showDialog(DLG_PROGRESS);//TODO:showDialogSafe(DLG_PROGRESS); + showDialog(DLG_PROGRESS); locationLookup.locateStations(); stationsFetched.sendEmptyMessageDelayed(LOCATIONFIXTIMEOUT, GPS_TIMEOUT_MS); @@ -402,7 +360,7 @@ void startNameSearch(String name) { dialogMessage = getString( stationlist_findbyname ); - showDialog(DLG_PROGRESS);//TODO:showDialogSafe(DLG_PROGRESS); + showDialog(DLG_PROGRESS); findStationsTask = new FindStationsTask(); findStationsTask.searchByName(name); @@ -414,7 +372,7 @@ if (favorites.size() > 0) { dialogMessage = getString( stationlist_loadfavorites ); - showDialog(DLG_PROGRESS);//TODO:showDialogSafe(DLG_PROGRESS); + showDialog(DLG_PROGRESS); findStationsTask = new FindStationsTask(); findStationsTask.searchByIds( favorites.toString() ); @@ -429,7 +387,7 @@ void startLocatorTask() { dialogMessage = getString( stationlist_findingnearby ); - showDialog(DLG_PROGRESS);//TODO:showDialogSafe(DLG_PROGRESS); + showDialog(DLG_PROGRESS); findStationsTask = new FindStationsTask(); findStationsTask.searchByLocation( locationLookup.getLocation() ); @@ -446,7 +404,7 @@ switch (msg.what) { case GOTLOCATION: - dismissDialog(DLG_PROGRESS);//TODO:dismissDialogSafe(DLG_PROGRESS); + dismissDialog(DLG_PROGRESS); startLocatorTask(); location = GeoPair.fromLocation( locationLookup.getLocation() ); @@ -454,7 +412,7 @@ break; case NOPROVIDER: - dismissDialog(DLG_PROGRESS);//TODO:dismissDialogSafe(DLG_PROGRESS); + dismissDialog(DLG_PROGRESS); MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider), true ); //StationList.this.finish(); break; @@ -464,7 +422,7 @@ if (locationLookup.hasLocation()) { stationsFetched.sendEmptyMessage( GOTLOCATION ); } else { - dismissDialog(DLG_PROGRESS);//TODO:dismissDialogSafe(DLG_PROGRESS); + dismissDialog(DLG_PROGRESS); AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this); builder.setMessage( getString( stationlist_gpstimeout) ); @@ -481,7 +439,7 @@ dialog.dismiss(); } }); - builder.show();//TODO:builderShowSafe(builder); + builder.show(); } } @@ -548,7 +506,7 @@ @Override protected void onPostExecute(Void result) { super.onPostExecute(result); - dialog.dismiss();//TODO:dismissDialogSafe(dialog); + dialog.dismiss(); if (stations != null) { @@ -606,7 +564,7 @@ } }); - builder.show();//TODO:builderShowSafe(builder); + builder.show(); } } }