/[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 484 by torben, Thu Oct 29 11:38:58 2009 UTC revision 701 by torben, Mon May 3 13:41:04 2010 UTC
# Line 2  package dk.thoerup.traininfo; Line 2  package dk.thoerup.traininfo;
2    
3  import java.util.ArrayList;  import java.util.ArrayList;
4  import java.util.List;  import java.util.List;
5  import java.util.Locale;  
6    
7  import android.app.AlertDialog;  import android.app.AlertDialog;
8  import android.app.Dialog;  import android.app.Dialog;
# Line 12  import android.content.DialogInterface; Line 12  import android.content.DialogInterface;
12  import android.content.Intent;  import android.content.Intent;
13  import android.content.SharedPreferences;  import android.content.SharedPreferences;
14  import android.content.SharedPreferences.Editor;  import android.content.SharedPreferences.Editor;
 import android.location.Address;  
 import android.location.Geocoder;  
15  import android.location.Location;  import android.location.Location;
16  import android.os.AsyncTask;  import android.os.AsyncTask;
17  import android.os.Bundle;  import android.os.Bundle;
18  import android.os.Handler;  import android.os.Handler;
19  import android.os.Message;  import android.os.Message;
20    
21  import android.util.Log;  import android.util.Log;
22  import android.view.ContextMenu;  import android.view.ContextMenu;
23  import android.view.LayoutInflater;  import android.view.LayoutInflater;
# Line 38  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 118  public class StationList extends ListAct Line 119  public class StationList extends ListAct
119                                  startLookup();                                  startLookup();
120                                  break;                                  break;
121                          case ListSearch:                          case ListSearch:
122                                  this.showDialog(DLG_STATIONNAME);                                  this.showDialogSafe(DLG_STATIONNAME);
123                                  break;                                  break;
124                          case ListFavorites:                          case ListFavorites:
125                                  startFavoriteLookup();                                  startFavoriteLookup();
# Line 135  public class StationList extends ListAct Line 136  public class StationList extends ListAct
136                                    
137          }          }
138          protected void setTitle() {          protected void setTitle() {
139                  String dialogTitle = getResources().getString(R.string.app_name);                  String dialogTitle = getResources().getString(app_name);
140                  switch (listType) {                  switch (listType) {
141                  case ListNearest:                  case ListNearest:
142                          dialogTitle += " - Nearby stations";                          dialogTitle += " - " + getString(stationlist_nearbystations);
143                          break;                          break;
144                  case ListSearch:                  case ListSearch:
145                          dialogTitle += " - Search";                          dialogTitle += " - " + getString(stationlist_search);
146                          break;                          break;
147                  case ListFavorites:                  case ListFavorites:
148                          dialogTitle += " - Favorites";                          dialogTitle += " - " + getString(stationlist_favorites);
149                          break;                          break;
150                  default:                  default:
151                          dialogTitle = "";//not possible                                                          dialogTitle = "";//not possible                                
152                  }                  }
153                    
154                  setTitle(dialogTitle);                  setTitle(dialogTitle);
155                    
156            }
157            
158            
159            /* these 3 dialogs helper functions are very rude and ugly hack
160             * to remove these auto-reported exceptions
161             * - android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@436aaef8 is not valid; is your activity running?
162             * - java.lang.IllegalArgumentException: View not attached to window manager
163             */
164            
165            public void showDialogSafe(int id) {
166                    try {
167                            showDialog(id);
168                    } catch (Exception e) {
169                            Log.e("StationList", "showDialog failed", e);
170                    }
171            }
172            
173            public void dismissDialogSafe(int id) {
174                    try {
175                            dismissDialog(id);
176                    } catch (Exception e) {
177                            Log.e("StationList", "dismissDialog failed", e);
178                    }
179          }          }
180                    
181            public void builderShowSafe(AlertDialog.Builder builder) {
182                    try {
183                            builder.show();
184                    } catch (Exception e) {
185                            Log.e("StationList", "builder.show() failed", e);
186                    }
187                    
188            }
189            /* EOF rude and ugly dialog hack */
190                    
191    
192    
# Line 171  public class StationList extends ListAct Line 205  public class StationList extends ListAct
205          @Override          @Override
206          public boolean onCreateOptionsMenu(Menu menu) {          public boolean onCreateOptionsMenu(Menu menu) {
207                  MenuItem item;                  MenuItem item;
208                                                    
209                  item = menu.add(0, OPTIONS_MAP, 0, "Station map");                  item = menu.add(0, OPTIONS_MAP, 0, getString(stationlist_stationmap));
210                  item.setIcon(android.R.drawable.ic_menu_mapmode);                  item.setIcon(android.R.drawable.ic_menu_mapmode);
211                                    
212                  item = menu.add(0, OPTIONS_GPSINFO, 0, "GPS Info");                  item = menu.add(0, OPTIONS_GPSINFO, 0, getString(stationlist_gpsinfo));
213                  item.setIcon(android.R.drawable.ic_menu_mapmode);                                item.setIcon(android.R.drawable.ic_menu_mapmode);              
214                                    
215                  return true;                  return true;
# Line 190  public class StationList extends ListAct Line 224  public class StationList extends ListAct
224                  case OPTIONS_MAP:                  case OPTIONS_MAP:
225                                                    
226                          Intent intent = new Intent(this,StationMapView.class);                          Intent intent = new Intent(this,StationMapView.class);
                         intent.putExtra("userlocation", location );  
227                                                    
228                          ArrayList<GeoPair> stationPoints = new ArrayList<GeoPair>();                          ArrayList<GeoPair> stationPoints = new ArrayList<GeoPair>();
229                          for (StationBean st : stations ) {                          for (StationBean st : stations ) {
# Line 204  public class StationList extends ListAct Line 237  public class StationList extends ListAct
237                  case OPTIONS_GPSINFO:                  case OPTIONS_GPSINFO:
238                          Location loc = locationLookup.getLocation();                          Location loc = locationLookup.getLocation();
239                          StringBuffer message = new StringBuffer();                          StringBuffer message = new StringBuffer();
240                          message.append("Location info:\n");                          message.append( getString(stationlist_locationinfo) ).append(":\n");
241                          message.append("-Obtained by: ").append(loc != null ? loc.getProvider() : "-").append("\n");                          if (loc != null) {
242                          message.append("-Accuracy: ").append(loc != null ? (int)loc.getAccuracy() : "-").append("m\n");                                  message.append( getString(stationlist_obtainedby) ).append( loc.getProvider() ).append("\n");
243                                    message.append( getString(stationlist_accuracy) ).append( (int)loc.getAccuracy()).append("m\n");
244                                    message.append( getString(stationlist_latitude) ).append( (float)loc.getLatitude()).append("\n");
245                                    message.append( getString(stationlist_longitude) ).append( (float)loc.getLongitude() ).append("\n");
246                            } else {
247                                    message.append( getString(stationlist_nolocation) );
248                            }                      
249                            
250                          MessageBox.showMessage(this, message.toString());                          MessageBox.showMessage(this, message.toString());
251                          break;                          break;
252                  default:                  default:
# Line 226  public class StationList extends ListAct Line 265  public class StationList extends ListAct
265    
266    
267          }          }
268            
269            public void showMessageAndClose(String message) {
270                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
271                    builder.setMessage(message)
272                    .setCancelable(false)
273                    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
274                            public void onClick(DialogInterface dialog, int id) {
275                                    dialog.dismiss();
276                                    StationList.this.finish();
277                            }
278                    })
279                    .show();
280            }
281    
282    
283    
# Line 235  public class StationList extends ListAct Line 287  public class StationList extends ListAct
287                  switch (id) {                  switch (id) {
288                  case DLG_PROGRESS:                  case DLG_PROGRESS:
289                          ProgressDialog dlg = new ProgressDialog(this);                          ProgressDialog dlg = new ProgressDialog(this);
290                          dlg.setMessage("Wait for location fix");                          dlg.setMessage( getString(stationlist_waitforlocation) );
291                          dlg.setCancelable(false);                          dlg.setCancelable(false);
292                          return dlg;                                              return dlg;                    
293                  case DLG_STATIONNAME:                  case DLG_STATIONNAME:
# Line 245  public class StationList extends ListAct Line 297  public class StationList extends ListAct
297                                                    
298                          AlertDialog.Builder builder = new AlertDialog.Builder(this);                          AlertDialog.Builder builder = new AlertDialog.Builder(this);
299                                                    
300                          builder.setTitle("Station search");                          builder.setTitle( getString(stationlist_stationsearch) );
301                          builder.setView(rootView);                          builder.setView(rootView);
302                          builder.setCancelable(true);                          builder.setCancelable(true);
303                          builder.setPositiveButton("Search", new DialogInterface.OnClickListener() {                          builder.setPositiveButton( getString(generic_search), new DialogInterface.OnClickListener() {
304                                  public void onClick(DialogInterface dialog, int which) {                                  public void onClick(DialogInterface dialog, int which) {
305                                          EditText et = (EditText) rootView.findViewById(R.id.EditText);                                          EditText et = (EditText) rootView.findViewById(R.id.EditText);
306                                          dialog.dismiss();                                          dialog.dismiss();
307                                          if (et.getText().toString().length() >= 2) {                                          if (et.getText().toString().length() >= 2) {
308                                                  startNameSearch(et.getText().toString());                                                  startNameSearch(et.getText().toString());
309                                          } else {                                          } else {
310                                                  MessageBox.showMessage(StationList.this, "Two characters minimum" );                                                  showMessageAndClose( getString(stationlist_twocharmin) );
311                                          }                                          }
312                                  }                                  }
313                          });                          });
314                          builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {                          builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {
315                                  public void onClick(DialogInterface dialog, int which) {                                  public void onClick(DialogInterface dialog, int which) {
316                                          dialog.dismiss();                                          dialog.dismiss();
317                                            StationList.this.finish(); // Close this Activity
318                                  }                                  }
319                          });                                              });                    
320                          return builder.create();                          return builder.create();
# Line 292  public class StationList extends ListAct Line 345  public class StationList extends ListAct
345                  super.onListItemClick(l, v, position, id);                  super.onListItemClick(l, v, position, id);
346                                                                    
347                  StationBean station = stations.get(position);                  StationBean station = stations.get(position);
   
                 double latitude = station.getLatitude();  
                 double longitude = station.getLongitude();  
   
   
348                                    
349                  Intent intent = new Intent(this, DepartureList.class);                  Intent intent = new Intent(this, DepartureList.class);
350                  intent.putExtra("name", station.getName());                  intent.putExtra("stationbean", station);
                 intent.putExtra("distance", station.getDistance());  
                 intent.putExtra("latitude", latitude);  
                 intent.putExtra("longitude", longitude);  
                 intent.putExtra("stationid", station.getId());  
                 intent.putExtra("address", station.getAddress());  
351                  startActivity(intent);                  startActivity(intent);
352          }          }
353    
# Line 312  public class StationList extends ListAct Line 355  public class StationList extends ListAct
355          //          //
356    
357          public void startLookup() {          public void startLookup() {
358                  isRunning = true;                  isRunning = true;              
359                  dialogMessage = "Wait for location fix";                  dialogMessage = getString( stationlist_waitforlocation );
360                  showDialog(DLG_PROGRESS);                  showDialogSafe(DLG_PROGRESS);
361                                    
362                  locationLookup.locateStations();                  locationLookup.locateStations();
363                  stationsFetched.sendEmptyMessageDelayed(LOCATIONFIXTIMEOUT, 20000);                  stationsFetched.sendEmptyMessageDelayed(LOCATIONFIXTIMEOUT, 20000);
364          }          }
365                    
366          void startNameSearch(String name) {          void startNameSearch(String name) {
367                  dialogMessage = "Finding stations by name";                  dialogMessage = getString( stationlist_findbyname );
368                  showDialog(DLG_PROGRESS);                  showDialogSafe(DLG_PROGRESS);
369    
370                  findStationsTask = new FindStationsTask();                  findStationsTask = new FindStationsTask();
371                  findStationsTask.searchByName(name, locationLookup.getLocation());                  findStationsTask.searchByName(name);
372                  findStationsTask.execute();                  findStationsTask.execute();
373                                    
374          }          }
# Line 333  public class StationList extends ListAct Line 376  public class StationList extends ListAct
376          public void startFavoriteLookup() {          public void startFavoriteLookup() {
377                                    
378                  if (favorites.size() > 0) {                  if (favorites.size() > 0) {
379                          dialogMessage = "Loading favorites";                          dialogMessage = getString( stationlist_loadfavorites );
380                          showDialog(DLG_PROGRESS);                          showDialogSafe(DLG_PROGRESS);
381    
382                          findStationsTask = new FindStationsTask();                          findStationsTask = new FindStationsTask();
383                          findStationsTask.searchByIds(favorites.toString(), locationLookup.getLocation());                          findStationsTask.searchByIds( favorites.toString() );
384                          findStationsTask.execute();                          findStationsTask.execute();
385                  } else {                  } else {
386                          MessageBox.showMessage(this, "Favorite list is empty");                          showMessageAndClose( getString( stationlist_nofavorites ) );
387                  }                  }
388          }          }
389    
# Line 348  public class StationList extends ListAct Line 391  public class StationList extends ListAct
391                    
392          void startLocatorTask()          void startLocatorTask()
393          {          {
394                  dialogMessage = "Finding nearby stations";                  dialogMessage = getString( stationlist_findingnearby );
395                  showDialog(DLG_PROGRESS);                  showDialogSafe(DLG_PROGRESS);
396                                    
397                  findStationsTask = new FindStationsTask();                  findStationsTask = new FindStationsTask();
398                  findStationsTask.searchByLocation( locationLookup.getLocation() );                  findStationsTask.searchByLocation( locationLookup.getLocation() );
399                  findStationsTask.execute();                      findStationsTask.execute();    
400          }          }
           
   
         String lookupAddress(double latitude, double longitude) {  
                   
                 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);  
                 }  
401                                    
                 return sb.toString();  
         }  
           
402                    
403          ////////////////////////////////////////////////////////////////////////////          ////////////////////////////////////////////////////////////////////////////
404          // Inner classes          // Inner classes
# Line 393  public class StationList extends ListAct Line 409  public class StationList extends ListAct
409    
410                          switch (msg.what) {                          switch (msg.what) {
411                          case GOTLOCATION:                          case GOTLOCATION:
412                                  dismissDialog(DLG_PROGRESS);                                  dismissDialogSafe(DLG_PROGRESS);
413                                                                    
414                                  startLocatorTask();                                  startLocatorTask();
415                                  location = GeoPair.fromLocation( locationLookup.getLocation() );                                  location = GeoPair.fromLocation( locationLookup.getLocation() );
# Line 401  public class StationList extends ListAct Line 417  public class StationList extends ListAct
417                                  break;                                  break;
418    
419                          case NOPROVIDER:                          case NOPROVIDER:
420                                  dismissDialog(DLG_PROGRESS);                                  dismissDialogSafe(DLG_PROGRESS);
421                                  MessageBox.showMessage(StationList.this,"No location provider enabled. Plase enable gps.");                                  MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider) );
422                                  break;                                  break;
423                          case LOCATIONFIXTIMEOUT:                                                          case LOCATIONFIXTIMEOUT:                                
424                                  if (isRunning) {                                  if (isRunning) {
# Line 410  public class StationList extends ListAct Line 426  public class StationList extends ListAct
426                                          if (locationLookup.hasLocation()) {                                          if (locationLookup.hasLocation()) {
427                                                  stationsFetched.sendEmptyMessage( GOTLOCATION );                                                  stationsFetched.sendEmptyMessage( GOTLOCATION );
428                                          } else {                                                                                          } else {                                                
429                                                  dismissDialog(DLG_PROGRESS);                                                  dismissDialogSafe(DLG_PROGRESS);
430                                                                                                    
431                                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                                                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                
432                                                  builder.setMessage("Location fix timed out");                                                  builder.setMessage(  getString( stationlist_gpstimeout) );
433                                                  builder.setCancelable(true);                                                  builder.setCancelable(true);
434                                                  builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() {                                                  builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {
435                                                          public void onClick(DialogInterface dialog, int id) {                                                          public void onClick(DialogInterface dialog, int id) {
436                                                                  dialog.dismiss();                                                                  dialog.dismiss();
437                                                                  startLookup();                                                                  startLookup();
438                                                                                                                                    
439                                                          }                                                          }
440                                                  });                                                  });
441                                                  builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {                                                  builder.setNegativeButton( getString(generic_cancel), new DialogInterface.OnClickListener() {
442                                                          public void onClick(DialogInterface dialog, int id) {                                                          public void onClick(DialogInterface dialog, int id) {
443                                                                  dialog.dismiss();                                                                  dialog.dismiss();
444                                                          }                                                                                                                }                                                      
445                                                  });                                                                                                                                              });
446                                                  builder.show();                                                  builderShowSafe(builder); // builder.show()
447    
448                                          }                                          }
449                                  }                                  }
# Line 446  public class StationList extends ListAct Line 462  public class StationList extends ListAct
462                  Location loc;                  Location loc;
463                  String ids;                  String ids;
464                                    
465                  public void searchByName(String n, Location l) {                  public void searchByName(String n) {
466                                                    
467                          method = LookupMethod.ByName;                          method = LookupMethod.ByName;
                         loc = l;  
468                          name = n;                          name = n;
469                  }                  }
470                                    
# Line 458  public class StationList extends ListAct Line 473  public class StationList extends ListAct
473                          loc = l;                          loc = l;
474                  }                  }
475                                    
476                  public void searchByIds(String id, Location l) {                  public void searchByIds(String id) {
477                                                    
478                          method = LookupMethod.ByList;                          method = LookupMethod.ByList;
                         loc = l;  
479                          ids = id;                          ids = id;
480                  }                  }
481                                    
# Line 491  public class StationList extends ListAct Line 505  public class StationList extends ListAct
505                          }                          }
506                                                    
507                                                    
                         Location dummy = new Location("gps");  
                         List<StationBean> stations = stationProvider.getStations();  
                           
                         for (StationBean station : stations) {  
                                 String addr = lookupAddress(station.getLatitude(), station.getLongitude());  
                                 station.setAddress(addr);  
                                   
                                   
                                 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);  
                                         }  
                                 }  
   
                         }                                                
                           
508                          return null;                          return null;
509                  }                  }
510    
# Line 521  public class StationList extends ListAct Line 515  public class StationList extends ListAct
515                                                    
516                                                    
517                          if (success) {                                                    if (success) {                          
518                                  if (stationProvider.getStations().size() == 0)                                  if (stationProvider.getStations().size() == 0) {
519                                          MessageBox.showMessage(StationList.this, "No stations found!"); // this should not be possible !?!                                          showMessageAndClose(getString(stationlist_nostations));
520                                    }
521                                  stations = stationProvider.getStations();                                  stations = stationProvider.getStations();
522                                  adapter.setStations( stations );                                                                  adapter.setStations( stations );                                
523                                                                    
524                          } else { //communication or parse errors                          } else { //communication or parse errors
525                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                
526                                  builder.setMessage("Error on finding nearby stations");                                  builder.setMessage(getString(stationlist_nearbyerror));                        
527                                  builder.setCancelable(true);                                  builder.setCancelable(true);
528                                  builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() {                                  builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {
529                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
530                                                  dialog.dismiss();                                                  dialog.dismiss();
531                                                                                                    
532                                                  stationsFetched.post( new Runnable() {                                                  Runnable runner = null;
533                                                          @Override                                                  switch (method) {
534                                                          public void run() {                                                  case ByLocation:
535                                                                  startLocatorTask();                                                                                                                      runner = new Runnable() {
536                                                          }                                                                  @Override
537                                                  });                                                                  public void run() {
538                                                                            startLocatorTask();                                                            
539                                                                    }
540                                                            };
541                                                            break;
542                                                    case ByName:
543                                                            runner = new Runnable() {
544                                                                    @Override
545                                                                    public void run() {
546                                                                            startNameSearch( FindStationsTask.this.name );
547                                                                    }
548                                                            };
549                                                            break;
550                                                    case ByList:
551                                                            runner = new Runnable() {
552                                                                    @Override
553                                                                    public void run() {
554                                                                            startFavoriteLookup();
555                                                                    }
556                                                            };
557                                                            break;
558                                                    }
559                                                    
560                                                    stationsFetched.post( runner );
561                                          }                                          }
562                                  });                                  });
563                                  builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {
564                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
565                                                  dialog.dismiss();                                                  dialog.dismiss();
566                                          }                                                                                                }                                                      
567                                  });                                                                                                                              });
568                                  builder.show();                                                          
569                                    builderShowSafe(builder); // builder.show()
570                          }                          }
571                  }                  }
572          }          }
# Line 568  public class StationList extends ListAct Line 587  public class StationList extends ListAct
587                          int stationID = stations.get(selectedPosition).getId();                          int stationID = stations.get(selectedPosition).getId();
588    
589                          if (!favorites.contains(stationID)) {                          if (!favorites.contains(stationID)) {
590                                  menu.add(0, FAVORITES_ADD, 0, "Add to favorites");                                  menu.add(0, FAVORITES_ADD, 0, getString(stationlist_addfavorite) );
591                          } else {                          } else {
592                                  menu.add(0, FAVORITES_REMOVE, 0, "Remove from favorites");                                  menu.add(0, FAVORITES_REMOVE, 0, getString(stationlist_removefavorite) );
593                          }                          }
594                                                    
595                  }                  }
# Line 581  public class StationList extends ListAct Line 600  public class StationList extends ListAct
600                          int stationID = sb.getId();                          int stationID = sb.getId();
601                          if (item.getItemId() == FAVORITES_ADD) {                          if (item.getItemId() == FAVORITES_ADD) {
602                                  favorites.add(stationID);                                  favorites.add(stationID);
603                                  Toast.makeText(StationList.this, "Station added", Toast.LENGTH_SHORT).show();                                  Toast.makeText(StationList.this, getString(stationlist_stationadded), Toast.LENGTH_SHORT).show();
604                          } else {                          } else {
605                                                                    
606                                  favorites.remove(stationID);                                  favorites.remove(stationID);
607                                  Toast.makeText(StationList.this, "Station removed", Toast.LENGTH_SHORT).show();                                  Toast.makeText(StationList.this, getString(stationlist_stationremoved), Toast.LENGTH_SHORT).show();
608                                                                    
609                                                                    
610                                  if (listType.equals( WelcomeScreen.ListType.ListFavorites) ) {                                  if (listType.equals( WelcomeScreen.ListType.ListFavorites) ) {

Legend:
Removed from v.484  
changed lines
  Added in v.701

  ViewVC Help
Powered by ViewVC 1.1.20