--- android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java 2010/01/27 06:14:00 556 +++ android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java 2010/01/27 10:04:28 557 @@ -35,9 +35,8 @@ ProgressDialog pgDialog; DepartureFetcher fetcher; - int stationId; - - double latitude,longitude; + + StationBean station; @SuppressWarnings("unchecked") @Override @@ -49,32 +48,27 @@ setListAdapter(adapter); Intent launchedBy = getIntent(); + + station = (StationBean) launchedBy.getSerializableExtra("stationbean"); - latitude = launchedBy.getDoubleExtra("latitude", 0.0); - longitude = launchedBy.getDoubleExtra("longitude", 0.0); - - String name = launchedBy.getStringExtra("name"); - ((TextView) findViewById(R.id.stationName)).setText( name ); + ((TextView) findViewById(R.id.stationName)).setText( station.getName() ); + - String address = launchedBy.getStringExtra("address"); - ((TextView) findViewById(R.id.stationAddr)).setText( address ); + ((TextView) findViewById(R.id.stationAddr)).setText( station.getAddress() ); - stationId = launchedBy.getIntExtra("stationid", -1); findViewById(R.id.header).setOnClickListener( mapLauncher ); NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(1); format.setMinimumFractionDigits(1); - int distance = launchedBy.getIntExtra("distance", 0); - ((TextView) findViewById(R.id.stationDistance)).setText( format.format((double)distance/1000.0) + " km." ); - boolean isRegional = launchedBy.getBooleanExtra("isregional", false); - boolean isSTrain = launchedBy.getBooleanExtra("isstrain", false); - //boolean isMetro = launchedBy.getBooleanExtra("ismetro", false); // not currently used + + int distance = station.getDistance(); + ((TextView) findViewById(R.id.stationDistance)).setText( format.format((double)distance/1000.0) + " km." ); - if (isRegional == false && isSTrain == false) { + if (station.isRegional() == false && station.isSTrain() == false) { getListView().setVisibility( View.GONE ); findViewById(R.id.metroonly).setVisibility( View.VISIBLE ); @@ -145,7 +139,7 @@ void startDepartureFetcher() { showDialog(DLG_PROGRESS); fetcher = new DepartureFetcher(); - fetcher.execute(stationId); + fetcher.execute(station.getId()); } class DialogDismisser implements View.OnClickListener { @@ -164,8 +158,8 @@ View.OnClickListener mapLauncher = new View.OnClickListener() { @Override - public void onClick(View v) { - Uri uri = Uri.parse("geo:" + latitude + "," + longitude); + public void onClick(View v) { + Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude()); startActivity( new Intent(Intent.ACTION_VIEW, uri)); } };