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

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

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

revision 556 by torben, Wed Jan 27 06:14:00 2010 UTC revision 1008 by torben, Tue Aug 3 06:36:29 2010 UTC
# Line 4  import java.util.ArrayList; Line 4  import java.util.ArrayList;
4  import java.util.List;  import java.util.List;
5    
6    
7    import android.app.Activity;
8  import android.app.AlertDialog;  import android.app.AlertDialog;
9  import android.app.Dialog;  import android.app.Dialog;
10  import android.app.ListActivity;  import android.app.ListActivity;
# Line 36  import dk.thoerup.traininfo.stationmap.S Line 37  import dk.thoerup.traininfo.stationmap.S
37  import dk.thoerup.traininfo.util.IntSet;  import dk.thoerup.traininfo.util.IntSet;
38  import dk.thoerup.traininfo.util.MessageBox;  import dk.thoerup.traininfo.util.MessageBox;
39    
40    import static dk.thoerup.traininfo.R.string.*;
41    
42  public class StationList extends ListActivity  {  public class StationList extends ListActivity  {
43          public static final int GOTLOCATION = 1001;          public static final int GOTLOCATION = 1001;
44          public static final int GOTSTATIONLIST = 1002;          public static final int GOTSTATIONLIST = 1002;
# Line 44  public class StationList extends ListAct Line 47  public class StationList extends ListAct
47                    
48          public static final int OPTIONS_MAP = 2003;          public static final int OPTIONS_MAP = 2003;
49          public static final int OPTIONS_GPSINFO = 2004;          public static final int OPTIONS_GPSINFO = 2004;
   
           
   
50                    
51          public static final int DLG_PROGRESS = 3001;          public static final int DLG_PROGRESS = 3001;
52          public static final int DLG_STATIONNAME = 3002;          public static final int DLG_STATIONNAME = 3002;
53                    
54            
55            public static final int GPS_TIMEOUT_MS = 17500; //how long are we willing to wait for gps fix -in milliseconds
56            
57            
58          static enum LookupMethod {          static enum LookupMethod {
59                  ByLocation,                  ByLocation,
60                  ByName,                  ByName,
# Line 66  public class StationList extends ListAct Line 70  public class StationList extends ListAct
70          StationsFetchedHandler stationsFetched = new StationsFetchedHandler();          StationsFetchedHandler stationsFetched = new StationsFetchedHandler();
71                    
72          GeoPair location = new GeoPair();          GeoPair location = new GeoPair();
73            
74            boolean isLaunchedforShortcut;
75          boolean isRunning = false;          boolean isRunning = false;
76          List<StationBean> stations = new ArrayList<StationBean>();          List<StationBean> stations = new ArrayList<StationBean>();
77                    
# Line 108  public class StationList extends ListAct Line 113  public class StationList extends ListAct
113                  listType = (WelcomeScreen.ListType) getIntent().getSerializableExtra("type");                  listType = (WelcomeScreen.ListType) getIntent().getSerializableExtra("type");
114                  setTitle();                  setTitle();
115                                    
116                    isLaunchedforShortcut = getIntent().getBooleanExtra("shortcut", false);
117                    
118                  if (savedInstanceState == null) {                  if (savedInstanceState == null) {
119    
120                                                    
# Line 115  public class StationList extends ListAct Line 122  public class StationList extends ListAct
122                          case ListNearest:                          case ListNearest:
123                                  startLookup();                                  startLookup();
124                                  break;                                  break;
125                          case ListSearch:                          case ListSearch:                                
126                                  this.showDialog(DLG_STATIONNAME);                                  showDialog(DLG_STATIONNAME);
127                                  break;                                  break;
128                          case ListFavorites:                          case ListFavorites:
129                                  startFavoriteLookup();                                  startFavoriteLookup();
# Line 132  public class StationList extends ListAct Line 139  public class StationList extends ListAct
139                  }                  }
140                                    
141          }          }
142            
143    
144            @Override
145            protected void onDestroy() {
146                    super.onDestroy();
147                    
148                    if (findStationsTask != null) {
149                            findStationsTask.cancel(true);
150                    }
151                    if (locationLookup != null) {
152                            locationLookup.stopSearch();
153                    }
154                    isRunning = false;
155            }
156    
157            
158          protected void setTitle() {          protected void setTitle() {
159                  String dialogTitle = getResources().getString(R.string.app_name);                  String dialogTitle = getResources().getString(app_name);
160                  switch (listType) {                  switch (listType) {
161                  case ListNearest:                  case ListNearest:
162                          dialogTitle += " - Nearby stations";                          dialogTitle += " - " + getString(stationlist_nearbystations);
163                          break;                          break;
164                  case ListSearch:                  case ListSearch:
165                          dialogTitle += " - Search";                          dialogTitle += " - " + getString(stationlist_search);
166                          break;                          break;
167                  case ListFavorites:                  case ListFavorites:
168                          dialogTitle += " - Favorites";                          dialogTitle += " - " + getString(stationlist_favorites);
169                          break;                          break;
170                  default:                  default:
171                          dialogTitle = "";//not possible                                                          dialogTitle = "";//not possible                                
172                  }                  }
173                    
174                  setTitle(dialogTitle);                  setTitle(dialogTitle);
175                    
176          }          }
177                    
178                            
   
179    
180      @Override      @Override
181      public void onSaveInstanceState(Bundle outState)      public void onSaveInstanceState(Bundle outState)
# Line 169  public class StationList extends ListAct Line 192  public class StationList extends ListAct
192          @Override          @Override
193          public boolean onCreateOptionsMenu(Menu menu) {          public boolean onCreateOptionsMenu(Menu menu) {
194                  MenuItem item;                  MenuItem item;
195                                                    
196                  item = menu.add(0, OPTIONS_MAP, 0, "Station map");                  item = menu.add(0, OPTIONS_MAP, 0, getString(stationlist_stationmap));
197                  item.setIcon(android.R.drawable.ic_menu_mapmode);                  item.setIcon(android.R.drawable.ic_menu_mapmode);
198                                    
199                  item = menu.add(0, OPTIONS_GPSINFO, 0, "GPS Info");                  item = menu.add(0, OPTIONS_GPSINFO, 0, getString(stationlist_gpsinfo));
200                  item.setIcon(android.R.drawable.ic_menu_mapmode);                                item.setIcon(android.R.drawable.ic_menu_mapmode);              
201                                    
202                  return true;                  return true;
# Line 201  public class StationList extends ListAct Line 224  public class StationList extends ListAct
224                  case OPTIONS_GPSINFO:                  case OPTIONS_GPSINFO:
225                          Location loc = locationLookup.getLocation();                          Location loc = locationLookup.getLocation();
226                          StringBuffer message = new StringBuffer();                          StringBuffer message = new StringBuffer();
227                          message.append("Location info:\n");                          message.append( getString(stationlist_locationinfo) ).append(":\n");
228                          if (loc != null) {                          if (loc != null) {
229                                  message.append("-Obtained by: ").append( loc.getProvider() ).append("\n");                                  message.append( getString(stationlist_obtainedby) ).append( loc.getProvider() ).append("\n");
230                                  message.append("-Accuracy: ").append( (int)loc.getAccuracy()).append("m\n");                                  message.append( getString(stationlist_accuracy) ).append( (int)loc.getAccuracy()).append("m\n");
231                                  message.append("-Latitude: ").append( loc.getLatitude()).append("\n");                                  message.append( getString(stationlist_latitude) ).append( (float)loc.getLatitude()).append("\n");
232                                  message.append("-Longitude: ").append( loc.getLongitude() ).append("\n");                                  message.append( getString(stationlist_longitude) ).append( (float)loc.getLongitude() ).append("\n");
233                          } else {                          } else {
234                                  message.append(" - No location data!");                                  message.append( getString(stationlist_nolocation) );
235                          }                                                }                      
236                                                    
237                          MessageBox.showMessage(this, message.toString());                          MessageBox.showMessage(this, message.toString(), false);
238                          break;                          break;
239                  default:                  default:
240                          retval = super.onOptionsItemSelected(item);                          retval = super.onOptionsItemSelected(item);
# Line 251  public class StationList extends ListAct Line 274  public class StationList extends ListAct
274                  switch (id) {                  switch (id) {
275                  case DLG_PROGRESS:                  case DLG_PROGRESS:
276                          ProgressDialog dlg = new ProgressDialog(this);                          ProgressDialog dlg = new ProgressDialog(this);
277                          dlg.setMessage("Wait for location fix");                          dlg.setMessage( getString(stationlist_waitforlocation) );
278                          dlg.setCancelable(false);                          dlg.setCancelable(false);
279                          return dlg;                                              return dlg;                    
280                  case DLG_STATIONNAME:                  case DLG_STATIONNAME:
# Line 261  public class StationList extends ListAct Line 284  public class StationList extends ListAct
284                                                    
285                          AlertDialog.Builder builder = new AlertDialog.Builder(this);                          AlertDialog.Builder builder = new AlertDialog.Builder(this);
286                                                    
287                          builder.setTitle("Station search");                          builder.setTitle( getString(stationlist_stationsearch) );
288                          builder.setView(rootView);                          builder.setView(rootView);
289                          builder.setCancelable(true);                          builder.setCancelable(true);
290                          builder.setPositiveButton("Search", new DialogInterface.OnClickListener() {                          builder.setPositiveButton( getString(generic_search), new DialogInterface.OnClickListener() {
291                                  public void onClick(DialogInterface dialog, int which) {                                  public void onClick(DialogInterface dialog, int which) {
292                                          EditText et = (EditText) rootView.findViewById(R.id.EditText);                                          EditText et = (EditText) rootView.findViewById(R.id.EditText);
293                                          dialog.dismiss();                                          dialog.dismiss();
294                                          if (et.getText().toString().length() >= 2) {                                          String search = et.getText().toString().trim();
295                                                  startNameSearch(et.getText().toString());                                          if (search.length() >= 2) {
296                                                    startNameSearch(search);
297                                          } else {                                          } else {
298                                                  showMessageAndClose("Two characters minimum");                                                  showMessageAndClose( getString(stationlist_twocharmin) );
299                                          }                                          }
300                                  }                                  }
301                          });                          });
302                          builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {                          builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {
303                                  public void onClick(DialogInterface dialog, int which) {                                  public void onClick(DialogInterface dialog, int which) {
304                                          dialog.dismiss();                                          dialog.dismiss();
305                                          StationList.this.finish(); // Close this Activity                                          StationList.this.finish(); // Close this Activity
# Line 309  public class StationList extends ListAct Line 333  public class StationList extends ListAct
333                  super.onListItemClick(l, v, position, id);                  super.onListItemClick(l, v, position, id);
334                                                                    
335                  StationBean station = stations.get(position);                  StationBean station = stations.get(position);
   
                 double latitude = station.getLatitude();  
                 double longitude = station.getLongitude();  
   
   
336                                    
337                  Intent intent = new Intent(this, DepartureList.class);                  if (isLaunchedforShortcut == true) {
338                  intent.putExtra("name", station.getName());                          Intent i = new Intent();
339                  intent.putExtra("distance", station.getDistance());                          i.putExtra("station", station);
340                  intent.putExtra("latitude", latitude);                          setResult(Activity.RESULT_OK, i);
341                  intent.putExtra("longitude", longitude);                          finish();
342                  intent.putExtra("stationid", station.getId());                  } else {                
343                  intent.putExtra("address", station.getAddress());                          Intent intent = new Intent(this, DepartureList.class);
344                  intent.putExtra("isregional", station.isRegional());                          intent.putExtra("stationbean", station);
345                  intent.putExtra("isstrain", station.isSTrain());                          startActivity(intent);
346                  intent.putExtra("ismetro", station.isMetro());                  }
                 startActivity(intent);  
347          }          }
348    
349          /////////////////////////////////////////////////////////////          /////////////////////////////////////////////////////////////
350          //          //
351    
352          public void startLookup() {          public void startLookup() {
353                  isRunning = true;                  isRunning = true;              
354                  dialogMessage = "Wait for location fix";                  dialogMessage = getString( stationlist_waitforlocation );
355                  showDialog(DLG_PROGRESS);                  showDialog(DLG_PROGRESS);
356                                    
357                  locationLookup.locateStations();                  locationLookup.locateStations();
358                  stationsFetched.sendEmptyMessageDelayed(LOCATIONFIXTIMEOUT, 20000);                  stationsFetched.sendEmptyMessageDelayed(LOCATIONFIXTIMEOUT, GPS_TIMEOUT_MS);
359          }          }
360                    
361          void startNameSearch(String name) {          void startNameSearch(String name) {
362                  dialogMessage = "Finding stations by name";                  dialogMessage = getString( stationlist_findbyname );
363                  showDialog(DLG_PROGRESS);                  showDialog(DLG_PROGRESS);
364    
365                  findStationsTask = new FindStationsTask();                  findStationsTask = new FindStationsTask();
366                  findStationsTask.searchByName(name, locationLookup.getLocation());                  findStationsTask.searchByName(name);
367                  findStationsTask.execute();                  findStationsTask.execute();
368                                    
369          }          }
# Line 353  public class StationList extends ListAct Line 371  public class StationList extends ListAct
371          public void startFavoriteLookup() {          public void startFavoriteLookup() {
372                                    
373                  if (favorites.size() > 0) {                  if (favorites.size() > 0) {
374                          dialogMessage = "Loading favorites";                          dialogMessage = getString( stationlist_loadfavorites );
375                          showDialog(DLG_PROGRESS);                          showDialog(DLG_PROGRESS);
376    
377                          findStationsTask = new FindStationsTask();                          findStationsTask = new FindStationsTask();
378                          findStationsTask.searchByIds(favorites.toString(), locationLookup.getLocation());                          findStationsTask.searchByIds( favorites.toString() );
379                          findStationsTask.execute();                          findStationsTask.execute();
380                  } else {                  } else {
381                          showMessageAndClose( "Favorite list is empty");                          showMessageAndClose( getString( stationlist_nofavorites ) );
382                  }                  }
383          }          }
384    
# Line 368  public class StationList extends ListAct Line 386  public class StationList extends ListAct
386                    
387          void startLocatorTask()          void startLocatorTask()
388          {          {
389                  dialogMessage = "Finding nearby stations";                  dialogMessage = getString( stationlist_findingnearby );
390                  showDialog(DLG_PROGRESS);                  showDialog(DLG_PROGRESS);
391                                    
392                  findStationsTask = new FindStationsTask();                  findStationsTask = new FindStationsTask();
393                  findStationsTask.searchByLocation( locationLookup.getLocation() );                  findStationsTask.searchByLocation( locationLookup.getLocation() );
394                  findStationsTask.execute();                      findStationsTask.execute();    
395          }          }
           
   
         /* TODO: Remove this no longer needed function  
         String lookupAddress(double latitude, double longitude) {  
396                                    
                 Geocoder coder = new Geocoder(this, new Locale("da"));  
                 StringBuilder sb = new StringBuilder();  
                 Log.i("lookupaddr", "" + latitude + "/" + longitude);  
                 try {  
                         List<Address> addressList = coder.getFromLocation(latitude, longitude, 1);  
                         Address addr = addressList.get(0);  
                           
                           
                         int max = addr.getMaxAddressLineIndex();  
                         for (int i=0; i<max; i++) {  
                                 if (i>0)  
                                         sb.append(", ");  
                                   
                                 sb.append(addr.getAddressLine(i));  
                         }  
                           
                           
                 } catch (Exception e) {  
                         Log.e("DepartureList", "geocoder failed", e);  
                 }  
                   
                 return sb.toString();  
         }*/  
           
397                    
398          ////////////////////////////////////////////////////////////////////////////          ////////////////////////////////////////////////////////////////////////////
399          // Inner classes          // Inner classes
# Line 423  public class StationList extends ListAct Line 413  public class StationList extends ListAct
413    
414                          case NOPROVIDER:                          case NOPROVIDER:
415                                  dismissDialog(DLG_PROGRESS);                                  dismissDialog(DLG_PROGRESS);
416                                  MessageBox.showMessage(StationList.this,"No location provider enabled. Plase enable gps.");                                  MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider), true );
417                                    //StationList.this.finish();
418                                  break;                                  break;
419                          case LOCATIONFIXTIMEOUT:                                                          case LOCATIONFIXTIMEOUT:                                
420                                  if (isRunning) {                                  if (isRunning) {
# Line 434  public class StationList extends ListAct Line 425  public class StationList extends ListAct
425                                                  dismissDialog(DLG_PROGRESS);                                                  dismissDialog(DLG_PROGRESS);
426                                                                                                    
427                                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                                                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                
428                                                  builder.setMessage("Location fix timed out");                                                  builder.setMessage(  getString( stationlist_gpstimeout) );
429                                                  builder.setCancelable(true);                                                  builder.setCancelable(true);
430                                                  builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() {                                                  builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {
431                                                          public void onClick(DialogInterface dialog, int id) {                                                          public void onClick(DialogInterface dialog, int id) {
432                                                                  dialog.dismiss();                                                                  dialog.dismiss();
433                                                                  startLookup();                                                                  startLookup();
434                                                                                                                                    
435                                                          }                                                          }
436                                                  });                                                  });
437                                                  builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {                                                  builder.setNegativeButton( getString(generic_cancel), new DialogInterface.OnClickListener() {
438                                                          public void onClick(DialogInterface dialog, int id) {                                                          public void onClick(DialogInterface dialog, int id) {
439                                                                  dialog.dismiss();                                                                  dialog.dismiss();
440                                                          }                                                                                                                }                                                      
441                                                  });                                                                                                                                              });
442                                                  builder.show();                                                  builder.show();
443    
444                                          }                                          }
445                                  }                                  }
# Line 462  public class StationList extends ListAct Line 453  public class StationList extends ListAct
453          class FindStationsTask extends AsyncTask<Void,Void,Void> {          class FindStationsTask extends AsyncTask<Void,Void,Void> {
454                                    
455                  LookupMethod method = LookupMethod.MethodNone;                  LookupMethod method = LookupMethod.MethodNone;
                 boolean success;  
456                  String name;                  String name;
457                  Location loc;                  Location loc;
458                  String ids;                  String ids;
459                                    
460                  public void searchByName(String n, Location l) {                  public void searchByName(String n) {
461                                                    
462                          method = LookupMethod.ByName;                          method = LookupMethod.ByName;
                         loc = l;  
463                          name = n;                          name = n;
464                  }                  }
465                                    
# Line 479  public class StationList extends ListAct Line 468  public class StationList extends ListAct
468                          loc = l;                          loc = l;
469                  }                  }
470                                    
471                  public void searchByIds(String id, Location l) {                  public void searchByIds(String id) {
472                                                    
473                          method = LookupMethod.ByList;                          method = LookupMethod.ByList;
                         loc = l;  
474                          ids = id;                          ids = id;
475                  }                  }
476                                    
# Line 499  public class StationList extends ListAct Line 487  public class StationList extends ListAct
487    
488                          switch (method) {                          switch (method) {
489                          case ByLocation:                          case ByLocation:
490                                  success = stationProvider.lookupStations(loc);                                  stations = stationProvider.lookupStations(loc);
491                                  break;                                  break;
492                          case ByName:                          case ByName:
493                                  success = stationProvider.lookupStationsByName(name);                                  stations = stationProvider.lookupStationsByName(name);
494                                  break;                                  break;
495                          case ByList:                          case ByList:
496                                  success = stationProvider.lookupStationsByIds(ids);                                  stations = stationProvider.lookupStationsByIds(ids);
497                                  break;                                  break;
498                          default:                          default:
499                                  success = false; // not possible                                          stations = null; // not possible        
500                          }                          }
501                                                    
502                                                    
                         Location dummy = new Location("gps");  
                         List<StationBean> stations = stationProvider.getStations();  
                           
                         for (StationBean station : stations) {  
                                                                   
                                 if (method.equals(LookupMethod.ByName) || method.equals(LookupMethod.ByList)) {  
                                         if (loc != null) { //only do the distance calc if we have a location  
                                                 dummy.setLatitude(station.getLatitude());  
                                                 dummy.setLongitude(station.getLongitude());  
                                                 station.setDistance( (int)loc.distanceTo(dummy) );  
                                         } else {  
                                                 station.setDistance(0);  
                                         }  
                                 }  
   
                         }                                                
                           
503                          return null;                          return null;
504                  }                  }
505    
# Line 538  public class StationList extends ListAct Line 509  public class StationList extends ListAct
509                          dialog.dismiss();                          dialog.dismiss();
510                                                    
511                                                    
512                          if (success) {                                                    if (stations != null) {                        
513                                  if (stationProvider.getStations().size() == 0)                                  if (stations.size() == 0) {
514                                          MessageBox.showMessage(StationList.this, "No stations found!"); // this should not be possible !?!                                          showMessageAndClose(getString(stationlist_nostations));
515                                  stations = stationProvider.getStations();                                  }
516    
517                                    StationList.this.getListView().invalidateViews();
518                                  adapter.setStations( stations );                                                                  adapter.setStations( stations );                                
519                                                                    
520                                    
521                          } else { //communication or parse errors                          } else { //communication or parse errors
522                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                
523                                  builder.setMessage("Error on finding nearby stations");                                  builder.setMessage(getString(stationlist_fetcherror));                          
524                                  builder.setCancelable(true);                                  builder.setCancelable(true);
525                                  builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() {                                  builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {
526                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
527                                                  dialog.dismiss();                                                  dialog.dismiss();
528                                                                                                    
529                                                  stationsFetched.post( new Runnable() {                                                  Runnable runner = null;
530                                                          @Override                                                  switch (method) {
531                                                          public void run() {                                                  case ByLocation:
532                                                                  startLocatorTask();                                                                                                                      runner = new Runnable() {
533                                                          }                                                                  @Override
534                                                  });                                                                  public void run() {
535                                                                            startLocatorTask();                                                            
536                                                                    }
537                                                            };
538                                                            break;
539                                                    case ByName:
540                                                            runner = new Runnable() {
541                                                                    @Override
542                                                                    public void run() {
543                                                                            startNameSearch( FindStationsTask.this.name );
544                                                                    }
545                                                            };
546                                                            break;
547                                                    case ByList:
548                                                            runner = new Runnable() {
549                                                                    @Override
550                                                                    public void run() {
551                                                                            startFavoriteLookup();
552                                                                    }
553                                                            };
554                                                            break;
555                                                    }
556                                                    
557                                                    stationsFetched.post( runner );
558                                          }                                          }
559                                  });                                  });
560                                  builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {
561                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
562                                                  dialog.dismiss();                                                  dialog.dismiss();
563                                                    StationList.this.finish();
564                                          }                                                                                                }                                                      
565                                  });                                                                                                                              });
566                                  builder.show();                                                          
567                                    builder.show();
568                          }                          }
569                  }                  }
570          }          }
# Line 586  public class StationList extends ListAct Line 585  public class StationList extends ListAct
585                          int stationID = stations.get(selectedPosition).getId();                          int stationID = stations.get(selectedPosition).getId();
586    
587                          if (!favorites.contains(stationID)) {                          if (!favorites.contains(stationID)) {
588                                  menu.add(0, FAVORITES_ADD, 0, "Add to favorites");                                  menu.add(0, FAVORITES_ADD, 0, getString(stationlist_addfavorite) );
589                          } else {                          } else {
590                                  menu.add(0, FAVORITES_REMOVE, 0, "Remove from favorites");                                  menu.add(0, FAVORITES_REMOVE, 0, getString(stationlist_removefavorite) );
591                          }                          }
592                                                    
593                  }                  }
# Line 599  public class StationList extends ListAct Line 598  public class StationList extends ListAct
598                          int stationID = sb.getId();                          int stationID = sb.getId();
599                          if (item.getItemId() == FAVORITES_ADD) {                          if (item.getItemId() == FAVORITES_ADD) {
600                                  favorites.add(stationID);                                  favorites.add(stationID);
601                                  Toast.makeText(StationList.this, "Station added", Toast.LENGTH_SHORT).show();                                  Toast.makeText(StationList.this, getString(stationlist_stationadded), Toast.LENGTH_SHORT).show();
602                          } else {                          } else {
603                                                                    
604                                  favorites.remove(stationID);                                  favorites.remove(stationID);
605                                  Toast.makeText(StationList.this, "Station removed", Toast.LENGTH_SHORT).show();                                  Toast.makeText(StationList.this, getString(stationlist_stationremoved), Toast.LENGTH_SHORT).show();
606                                                                    
607                                                                    
608                                  if (listType.equals( WelcomeScreen.ListType.ListFavorites) ) {                                  if (listType.equals( WelcomeScreen.ListType.ListFavorites) ) {

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

  ViewVC Help
Powered by ViewVC 1.1.20