/[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 552 by torben, Tue Jan 26 21:17:26 2010 UTC revision 575 by torben, Tue Feb 2 08:34:00 2010 UTC
# Line 19  import android.widget.TextView; Line 19  import android.widget.TextView;
19  import dk.thoerup.traininfo.provider.DepartureProvider;  import dk.thoerup.traininfo.provider.DepartureProvider;
20  import dk.thoerup.traininfo.provider.ProviderFactory;  import dk.thoerup.traininfo.provider.ProviderFactory;
21  import dk.thoerup.traininfo.util.MessageBox;  import dk.thoerup.traininfo.util.MessageBox;
22    import static dk.thoerup.traininfo.R.string.*;
23    
24  public class DepartureList extends ListActivity {  public class DepartureList extends ListActivity {
25    
# Line 35  public class DepartureList extends ListA Line 36  public class DepartureList extends ListA
36          ProgressDialog pgDialog;          ProgressDialog pgDialog;
37                    
38          DepartureFetcher fetcher;          DepartureFetcher fetcher;
39          int stationId;  
40                    StationBean station;
         double latitude,longitude;  
41                    
42          @SuppressWarnings("unchecked")          @SuppressWarnings("unchecked")
43          @Override          @Override
# Line 49  public class DepartureList extends ListA Line 49  public class DepartureList extends ListA
49                  setListAdapter(adapter);                  setListAdapter(adapter);
50                                    
51                  Intent launchedBy = getIntent();                  Intent launchedBy = getIntent();
52            
53                    station = (StationBean) launchedBy.getSerializableExtra("stationbean");
54                                    
55                  latitude = launchedBy.getDoubleExtra("latitude", 0.0);                  ((TextView) findViewById(R.id.stationName)).setText( station.getName() );
56                  longitude = launchedBy.getDoubleExtra("longitude", 0.0);  
                   
                 String name = launchedBy.getStringExtra("name");  
                 ((TextView) findViewById(R.id.stationName)).setText( name );  
57    
58                  String address = launchedBy.getStringExtra("address");                  ((TextView) findViewById(R.id.stationAddr)).setText( station.getAddress() );
                 ((TextView) findViewById(R.id.stationAddr)).setText( address );  
59                                    
                 stationId = launchedBy.getIntExtra("stationid", -1);  
60                                    
61                  findViewById(R.id.header).setOnClickListener( mapLauncher );                  findViewById(R.id.header).setOnClickListener( mapLauncher );
62                                    
63                  NumberFormat format = NumberFormat.getNumberInstance();                  NumberFormat format = NumberFormat.getNumberInstance();
64                  format.setMaximumFractionDigits(1);                  format.setMaximumFractionDigits(1);
65                  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." );  
66                                    
67                  boolean isRegional = launchedBy.getBooleanExtra("isregional", false);  
68                  boolean isSTrain = launchedBy.getBooleanExtra("isstrain", false);                  int distance = station.getDistance();
69                  //boolean isMetro = launchedBy.getBooleanExtra("ismetro", false); // not currently used                  ((TextView) findViewById(R.id.stationDistance)).setText( format.format((double)distance/1000.0) + " km." );
70                                    
71                    
72                  if (isRegional == false && isSTrain == false) {                  if (station.isRegional() == false && station.isSTrain() == false) {
73                          getListView().setVisibility( View.GONE );                                        getListView().setVisibility( View.GONE );              
74                          findViewById(R.id.metroonly).setVisibility( View.VISIBLE );                          findViewById(R.id.metroonly).setVisibility( View.VISIBLE );
75                                                    
# Line 134  public class DepartureList extends ListA Line 129  public class DepartureList extends ListA
129                  switch (id) {                  switch (id) {
130                  case DLG_PROGRESS:                  case DLG_PROGRESS:
131                          ProgressDialog dlg = new ProgressDialog(this);                          ProgressDialog dlg = new ProgressDialog(this);
132                          dlg.setMessage("Fetch departure data");                          dlg.setMessage( getString(departurelist_fetchdata) );
133                          dlg.setCancelable(true);                          dlg.setCancelable(true);
134                          return dlg;                                              return dlg;                    
135                  default:                  default:
# Line 145  public class DepartureList extends ListA Line 140  public class DepartureList extends ListA
140          void startDepartureFetcher() {          void startDepartureFetcher() {
141                  showDialog(DLG_PROGRESS);                  showDialog(DLG_PROGRESS);
142                  fetcher = new DepartureFetcher();                  fetcher = new DepartureFetcher();
143                  fetcher.execute(stationId);                  fetcher.execute(station.getId());
144          }          }
145                    
146          class DialogDismisser implements View.OnClickListener {          class DialogDismisser implements View.OnClickListener {
# Line 164  public class DepartureList extends ListA Line 159  public class DepartureList extends ListA
159                    
160          View.OnClickListener mapLauncher = new View.OnClickListener() {          View.OnClickListener mapLauncher = new View.OnClickListener() {
161                  @Override                  @Override
162                  public void onClick(View v) {                  public void onClick(View v) {                  
163                          Uri uri = Uri.parse("geo:" + latitude + "," + longitude);                          Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude());
164                          startActivity( new Intent(Intent.ACTION_VIEW, uri));                          startActivity( new Intent(Intent.ACTION_VIEW, uri));
165                  }                  }
166          };          };
# Line 192  public class DepartureList extends ListA Line 187  public class DepartureList extends ListA
187                                  AlertDialog.Builder builder = new AlertDialog.Builder(DepartureList.this);                                                                                AlertDialog.Builder builder = new AlertDialog.Builder(DepartureList.this);                                              
188                                  builder.setMessage("Error finding departures");                                  builder.setMessage("Error finding departures");
189                                  builder.setCancelable(true);                                  builder.setCancelable(true);
190                                  builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() {                                  builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {
191                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
192                                                  dialog.dismiss();                                                  dialog.dismiss();
193                                                  startDepartureFetcher();                                                  startDepartureFetcher();
194                                                                                                    
195                                          }                                          }
196                                  });                                  });
197                                  builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {
198                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
199                                                  dialog.dismiss();                                                  dialog.dismiss();
200                                          }                                                                                                }                                                      

Legend:
Removed from v.552  
changed lines
  Added in v.575

  ViewVC Help
Powered by ViewVC 1.1.20