/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java
ViewVC logotype

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 556 by torben, Tue Jan 26 21:17:26 2010 UTC revision 557 by torben, Wed Jan 27 10:04:28 2010 UTC
# Line 35  public class DepartureList extends ListA Line 35  public class DepartureList extends ListA
35          ProgressDialog pgDialog;          ProgressDialog pgDialog;
36                    
37          DepartureFetcher fetcher;          DepartureFetcher fetcher;
38          int stationId;  
39                    StationBean station;
         double latitude,longitude;  
40                    
41          @SuppressWarnings("unchecked")          @SuppressWarnings("unchecked")
42          @Override          @Override
# Line 49  public class DepartureList extends ListA Line 48  public class DepartureList extends ListA
48                  setListAdapter(adapter);                  setListAdapter(adapter);
49                                    
50                  Intent launchedBy = getIntent();                  Intent launchedBy = getIntent();
51            
52                    station = (StationBean) launchedBy.getSerializableExtra("stationbean");
53                                    
54                  latitude = launchedBy.getDoubleExtra("latitude", 0.0);                  ((TextView) findViewById(R.id.stationName)).setText( station.getName() );
55                  longitude = launchedBy.getDoubleExtra("longitude", 0.0);  
                   
                 String name = launchedBy.getStringExtra("name");  
                 ((TextView) findViewById(R.id.stationName)).setText( name );  
56    
57                  String address = launchedBy.getStringExtra("address");                  ((TextView) findViewById(R.id.stationAddr)).setText( station.getAddress() );
                 ((TextView) findViewById(R.id.stationAddr)).setText( address );  
58                                    
                 stationId = launchedBy.getIntExtra("stationid", -1);  
59                                    
60                  findViewById(R.id.header).setOnClickListener( mapLauncher );                  findViewById(R.id.header).setOnClickListener( mapLauncher );
61                                    
62                  NumberFormat format = NumberFormat.getNumberInstance();                  NumberFormat format = NumberFormat.getNumberInstance();
63                  format.setMaximumFractionDigits(1);                  format.setMaximumFractionDigits(1);
64                  format.setMinimumFractionDigits(1);                  format.setMinimumFractionDigits(1);
                 int distance = launchedBy.getIntExtra("distance", 0);  
                 ((TextView) findViewById(R.id.stationDistance)).setText( format.format((double)distance/1000.0) + " km." );  
65                                    
66                  boolean isRegional = launchedBy.getBooleanExtra("isregional", false);  
67                  boolean isSTrain = launchedBy.getBooleanExtra("isstrain", false);                  int distance = station.getDistance();
68                  //boolean isMetro = launchedBy.getBooleanExtra("ismetro", false); // not currently used                  ((TextView) findViewById(R.id.stationDistance)).setText( format.format((double)distance/1000.0) + " km." );
69                                    
70                    
71                  if (isRegional == false && isSTrain == false) {                  if (station.isRegional() == false && station.isSTrain() == false) {
72                          getListView().setVisibility( View.GONE );                                        getListView().setVisibility( View.GONE );              
73                          findViewById(R.id.metroonly).setVisibility( View.VISIBLE );                          findViewById(R.id.metroonly).setVisibility( View.VISIBLE );
74                                                    
# Line 145  public class DepartureList extends ListA Line 139  public class DepartureList extends ListA
139          void startDepartureFetcher() {          void startDepartureFetcher() {
140                  showDialog(DLG_PROGRESS);                  showDialog(DLG_PROGRESS);
141                  fetcher = new DepartureFetcher();                  fetcher = new DepartureFetcher();
142                  fetcher.execute(stationId);                  fetcher.execute(station.getId());
143          }          }
144                    
145          class DialogDismisser implements View.OnClickListener {          class DialogDismisser implements View.OnClickListener {
# Line 164  public class DepartureList extends ListA Line 158  public class DepartureList extends ListA
158                    
159          View.OnClickListener mapLauncher = new View.OnClickListener() {          View.OnClickListener mapLauncher = new View.OnClickListener() {
160                  @Override                  @Override
161                  public void onClick(View v) {                  public void onClick(View v) {                  
162                          Uri uri = Uri.parse("geo:" + latitude + "," + longitude);                          Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude());
163                          startActivity( new Intent(Intent.ACTION_VIEW, uri));                          startActivity( new Intent(Intent.ACTION_VIEW, uri));
164                  }                  }
165          };          };

Legend:
Removed from v.556  
changed lines
  Added in v.557

  ViewVC Help
Powered by ViewVC 1.1.20