--- android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/01/26 21:17:26 552 +++ android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/01/27 06:14:00 556 @@ -202,10 +202,15 @@ Location loc = locationLookup.getLocation(); StringBuffer message = new StringBuffer(); message.append("Location info:\n"); - message.append("-Obtained by: ").append(loc != null ? loc.getProvider() : "-").append("\n"); - message.append("-Accuracy: ").append(loc != null ? (int)loc.getAccuracy() : "-").append("m\n"); - message.append("-Latitude: ").append(loc != null ? loc.getLatitude() : "-").append("\n"); - message.append("-Longitude: ").append(loc != null ? loc.getLongitude() : "-").append("\n"); + if (loc != null) { + message.append("-Obtained by: ").append( loc.getProvider() ).append("\n"); + message.append("-Accuracy: ").append( (int)loc.getAccuracy()).append("m\n"); + message.append("-Latitude: ").append( loc.getLatitude()).append("\n"); + message.append("-Longitude: ").append( loc.getLongitude() ).append("\n"); + } else { + message.append(" - No location data!"); + } + MessageBox.showMessage(this, message.toString()); break; default: @@ -224,6 +229,19 @@ } + + public void showMessageAndClose(String message) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage(message) + .setCancelable(false) + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + StationList.this.finish(); + } + }) + .show(); + } @@ -253,13 +271,14 @@ if (et.getText().toString().length() >= 2) { startNameSearch(et.getText().toString()); } else { - MessageBox.showMessage(StationList.this, "Two characters minimum" ); + showMessageAndClose("Two characters minimum"); } } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); + StationList.this.finish(); // Close this Activity } }); return builder.create(); @@ -341,7 +360,7 @@ findStationsTask.searchByIds(favorites.toString(), locationLookup.getLocation()); findStationsTask.execute(); } else { - MessageBox.showMessage(this, "Favorite list is empty"); + showMessageAndClose( "Favorite list is empty"); } }