--- android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/01/27 05:51:45 554 +++ android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/01/27 10:04:28 557 @@ -209,8 +209,8 @@ message.append("-Longitude: ").append( loc.getLongitude() ).append("\n"); } else { message.append(" - No location data!"); - } - + } + MessageBox.showMessage(this, message.toString()); break; default: @@ -229,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(); + } @@ -258,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(); @@ -295,22 +309,9 @@ super.onListItemClick(l, v, position, id); StationBean station = stations.get(position); - - double latitude = station.getLatitude(); - double longitude = station.getLongitude(); - - Intent intent = new Intent(this, DepartureList.class); - intent.putExtra("name", station.getName()); - intent.putExtra("distance", station.getDistance()); - intent.putExtra("latitude", latitude); - intent.putExtra("longitude", longitude); - intent.putExtra("stationid", station.getId()); - intent.putExtra("address", station.getAddress()); - intent.putExtra("isregional", station.isRegional()); - intent.putExtra("isstrain", station.isSTrain()); - intent.putExtra("ismetro", station.isMetro()); + intent.putExtra("stationbean", station); startActivity(intent); } @@ -346,7 +347,7 @@ findStationsTask.searchByIds(favorites.toString(), locationLookup.getLocation()); findStationsTask.execute(); } else { - MessageBox.showMessage(this, "Favorite list is empty"); + showMessageAndClose( "Favorite list is empty"); } }