/[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 1433 by torben, Tue May 3 12:38:04 2011 UTC revision 1434 by torben, Tue May 3 16:28:56 2011 UTC
# Line 44  public class DepartureList extends ListA Line 44  public class DepartureList extends ListA
44          public static final int DLG_PROGRESS = 1;          public static final int DLG_PROGRESS = 1;
45          static final int MENU_MAP = 100;          static final int MENU_MAP = 100;
46          static final int MENU_NOTIFICATIONS = 101;          static final int MENU_NOTIFICATIONS = 101;
47          static final int MENU_METROMAP= 102;          static final int MENU_METROMAP = 102;
48            static final int MENU_TOGGLEDETAILS= 103;
49                    
50                    
51          DepartureListAdapter adapter;          DepartureListAdapter adapter;
# Line 66  public class DepartureList extends ListA Line 67  public class DepartureList extends ListA
67                    
68          String trainType = "REGIONAL";          String trainType = "REGIONAL";
69                    
70          boolean arrival = false;          boolean arrival = false;        
71    
72          int commFailCounter = 0;          int commFailCounter = 0;
73    
# Line 76  public class DepartureList extends ListA Line 77  public class DepartureList extends ListA
77                  setContentView(R.layout.departurelist);                  setContentView(R.layout.departurelist);
78                                    
79                  adapter = new DepartureListAdapter(this);                  adapter = new DepartureListAdapter(this);
80                  setListAdapter(adapter);                  setListAdapter(adapter);                                
81                                    
82                  Intent launchedBy = getIntent();                  Intent launchedBy = getIntent();
83                    
# Line 337  public class DepartureList extends ListA Line 338  public class DepartureList extends ListA
338                    
339                    
340    
   
   
341          @Override          @Override
342          public boolean onCreateOptionsMenu(Menu menu) {          public boolean onCreateOptionsMenu(Menu menu) {
343                  MenuItem item;                  MenuItem item;
344                                    
345                    
346                    item = menu.add(0, MENU_TOGGLEDETAILS, 0, getString(R.string.departurelist_toggledetails));
347                    item.setIcon(android.R.drawable.ic_menu_view);
348                    
349                  item = menu.add(0, MENU_MAP, 0, getString(R.string.departurelist_showonmap) );                  item = menu.add(0, MENU_MAP, 0, getString(R.string.departurelist_showonmap) );
350                  item.setIcon(android.R.drawable.ic_menu_mapmode);                  item.setIcon(android.R.drawable.ic_menu_mapmode);
351                                    
# Line 355  public class DepartureList extends ListA Line 358  public class DepartureList extends ListA
358                  if (station.isMetro()) {                  if (station.isMetro()) {
359                          item = menu.add(0, MENU_METROMAP, 0, "Metro" ); //TODO:translate!?!                          item = menu.add(0, MENU_METROMAP, 0, "Metro" ); //TODO:translate!?!
360                          item.setIcon(android.R.drawable.ic_menu_mapmode);                                                item.setIcon(android.R.drawable.ic_menu_mapmode);                      
361                  }                  }                                              
                   
362    
363                  return true;                  return true;
364          }          }
365    
366          @Override          @Override
367          public boolean onOptionsItemSelected(MenuItem item) {                    public boolean onOptionsItemSelected(MenuItem item) {          
368                  boolean res;                  boolean res = true;
369                  switch(item.getItemId()) {                  switch(item.getItemId()) {
370                  case MENU_MAP:                  case MENU_MAP:
371                          try {                          Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude() + "?z=16");
372                                  Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude() + "?z=16");                          
373                            try {                          
374                                  startActivity( new Intent(Intent.ACTION_VIEW, uri));                                  startActivity( new Intent(Intent.ACTION_VIEW, uri));
375                          } catch (ActivityNotFoundException anfe) {                          } catch (ActivityNotFoundException anfe) {
376                                   Toast.makeText(this, "Could not launch google maps", Toast.LENGTH_LONG).show();                                   Toast.makeText(this, "Could not launch google maps", Toast.LENGTH_LONG).show();
377                          }                          }
378                          res = true;                          
379                          break;                          break;
380                  case MENU_NOTIFICATIONS:                  case MENU_NOTIFICATIONS:
381                          Intent i = new Intent(this,dk.thoerup.traininfo.NotificationList.class);                          Intent i = new Intent(this,dk.thoerup.traininfo.NotificationList.class);
382                          i.putExtra(NotificationList.EXTRA_NOTIFICATIONS, departures.notifications);                          i.putExtra(NotificationList.EXTRA_NOTIFICATIONS, departures.notifications);
383                          startActivity(i);                          startActivity(i);                      
                         res = true;  
384                          break;                          break;
385                  case MENU_METROMAP:                  case MENU_METROMAP:
386                          Intent metroMap = new Intent(this,dk.thoerup.traininfo.MetroMap.class);                          Intent metroMap = new Intent(this,dk.thoerup.traininfo.MetroMap.class);
387                          startActivity(metroMap);                          startActivity(metroMap);                        
                         res = true;  
388                          break;                                            break;                  
389                    case MENU_TOGGLEDETAILS:
390                            adapter.toggleShowDetails();                                            
391                            break;
392                  default:                  default:
393                          res = super.onOptionsItemSelected(item);                          res = super.onOptionsItemSelected(item);
394                  }                  }

Legend:
Removed from v.1433  
changed lines
  Added in v.1434

  ViewVC Help
Powered by ViewVC 1.1.20