--- android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/06/26 11:06:12 919 +++ android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/07/11 15:29:13 984 @@ -19,7 +19,6 @@ import android.os.Handler; import android.os.Message; -import android.util.Log; import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.Menu; @@ -48,13 +47,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, @@ -122,8 +122,8 @@ case ListNearest: startLookup(); break; - case ListSearch: - this.showDialogSafe(DLG_STATIONNAME); + case ListSearch: + showDialog(DLG_STATIONNAME); //TODO: this.showDialogSafe(DLG_STATIONNAME); break; case ListFavorites: startFavoriteLookup(); @@ -181,7 +181,8 @@ * - 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); @@ -212,7 +213,8 @@ Log.e("StationList", "builder.show() failed", e); } - } + }*/ + /* EOF rude and ugly dialog hack */ @@ -392,15 +394,15 @@ public void startLookup() { isRunning = true; dialogMessage = getString( stationlist_waitforlocation ); - showDialogSafe(DLG_PROGRESS); + showDialog(DLG_PROGRESS);//TODO:showDialogSafe(DLG_PROGRESS); locationLookup.locateStations(); - stationsFetched.sendEmptyMessageDelayed(LOCATIONFIXTIMEOUT, 20000); + stationsFetched.sendEmptyMessageDelayed(LOCATIONFIXTIMEOUT, GPS_TIMEOUT_MS); } void startNameSearch(String name) { dialogMessage = getString( stationlist_findbyname ); - showDialogSafe(DLG_PROGRESS); + showDialog(DLG_PROGRESS);//TODO:showDialogSafe(DLG_PROGRESS); findStationsTask = new FindStationsTask(); findStationsTask.searchByName(name); @@ -412,7 +414,7 @@ if (favorites.size() > 0) { dialogMessage = getString( stationlist_loadfavorites ); - showDialogSafe(DLG_PROGRESS); + showDialog(DLG_PROGRESS);//TODO:showDialogSafe(DLG_PROGRESS); findStationsTask = new FindStationsTask(); findStationsTask.searchByIds( favorites.toString() ); @@ -427,7 +429,7 @@ void startLocatorTask() { dialogMessage = getString( stationlist_findingnearby ); - showDialogSafe(DLG_PROGRESS); + showDialog(DLG_PROGRESS);//TODO:showDialogSafe(DLG_PROGRESS); findStationsTask = new FindStationsTask(); findStationsTask.searchByLocation( locationLookup.getLocation() ); @@ -444,7 +446,7 @@ switch (msg.what) { case GOTLOCATION: - dismissDialogSafe(DLG_PROGRESS); + dismissDialog(DLG_PROGRESS);//TODO:dismissDialogSafe(DLG_PROGRESS); startLocatorTask(); location = GeoPair.fromLocation( locationLookup.getLocation() ); @@ -452,7 +454,7 @@ break; case NOPROVIDER: - dismissDialogSafe(DLG_PROGRESS); + dismissDialog(DLG_PROGRESS);//TODO:dismissDialogSafe(DLG_PROGRESS); MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider), true ); //StationList.this.finish(); break; @@ -462,7 +464,7 @@ if (locationLookup.hasLocation()) { stationsFetched.sendEmptyMessage( GOTLOCATION ); } else { - dismissDialogSafe(DLG_PROGRESS); + dismissDialog(DLG_PROGRESS);//TODO:dismissDialogSafe(DLG_PROGRESS); AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this); builder.setMessage( getString( stationlist_gpstimeout) ); @@ -479,7 +481,7 @@ dialog.dismiss(); } }); - builderShowSafe(builder); // builder.show() + builder.show();//TODO:builderShowSafe(builder); } } @@ -547,7 +549,7 @@ @Override protected void onPostExecute(Void result) { super.onPostExecute(result); - dismissDialogSafe(dialog); + dialog.dismiss();//TODO:dismissDialogSafe(dialog); if (success) { @@ -606,7 +608,7 @@ } }); - builderShowSafe(builder); // builder.show() + builder.show();//TODO:builderShowSafe(builder); } } }