/[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 481 by torben, Thu Oct 29 08:56:17 2009 UTC revision 579 by torben, Tue Feb 2 08:52:45 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  import android.util.Log;  
21  import android.view.ContextMenu;  import android.view.ContextMenu;
22  import android.view.LayoutInflater;  import android.view.LayoutInflater;
23  import android.view.Menu;  import android.view.Menu;
# Line 38  import dk.thoerup.traininfo.stationmap.S Line 36  import dk.thoerup.traininfo.stationmap.S
36  import dk.thoerup.traininfo.util.IntSet;  import dk.thoerup.traininfo.util.IntSet;
37  import dk.thoerup.traininfo.util.MessageBox;  import dk.thoerup.traininfo.util.MessageBox;
38    
39    import static dk.thoerup.traininfo.R.string.*;
40    
41  public class StationList extends ListActivity  {  public class StationList extends ListActivity  {
42          public static final int GOTLOCATION = 1001;          public static final int GOTLOCATION = 1001;
43          public static final int GOTSTATIONLIST = 1002;          public static final int GOTSTATIONLIST = 1002;
# Line 63  public class StationList extends ListAct Line 63  public class StationList extends ListAct
63                    
64          String dialogMessage = "";          String dialogMessage = "";
65          ProgressDialog dialog;          ProgressDialog dialog;
66          LocationLookup locator = null;          LocationLookup locationLookup = null;
67          FindStationsTask findStationsTask;          FindStationsTask findStationsTask;
68          StationsFetchedHandler stationsFetched = new StationsFetchedHandler();          StationsFetchedHandler stationsFetched = new StationsFetchedHandler();
69                    
# Line 80  public class StationList extends ListAct Line 80  public class StationList extends ListAct
80          IntSet favorites = new IntSet();          IntSet favorites = new IntSet();
81    
82          WelcomeScreen.ListType listType;          WelcomeScreen.ListType listType;
         String dialogTitle;  
83          SharedPreferences prefs;          SharedPreferences prefs;
84                    
85          ///////////////////////////////////////////////////////////////////////////////////////////          ///////////////////////////////////////////////////////////////////////////////////////////
# Line 99  public class StationList extends ListAct Line 98  public class StationList extends ListAct
98                  ListView lv = getListView();                  ListView lv = getListView();
99                  lv.setOnCreateContextMenuListener(contextMenu);                  lv.setOnCreateContextMenuListener(contextMenu);
100                                    
101                  locator = new LocationLookup(this, stationsFetched);                  locationLookup = new LocationLookup(this, stationsFetched);
102                                    
103    
104                  prefs = getSharedPreferences("TrainStation", 0);                  prefs = getSharedPreferences("TrainStation", 0);
# Line 108  public class StationList extends ListAct Line 107  public class StationList extends ListAct
107                          favorites.fromString(favoriteString);                          favorites.fromString(favoriteString);
108                  }                  }
109                                    
110                    listType = (WelcomeScreen.ListType) getIntent().getSerializableExtra("type");
111                    setTitle();
112                    
113                  if (savedInstanceState == null) {                  if (savedInstanceState == null) {
114                          listType = (WelcomeScreen.ListType) getIntent().getSerializableExtra("type");  
115                            
116                          switch (listType) {                          switch (listType) {
117                          case ListNearest:                          case ListNearest:
118                                  startLookup();                                  startLookup();
# Line 128  public class StationList extends ListAct Line 131  public class StationList extends ListAct
131                          stations = (ArrayList<StationBean>) savedInstanceState.getSerializable("stations");                          stations = (ArrayList<StationBean>) savedInstanceState.getSerializable("stations");
132                          adapter.setStations(stations);                          adapter.setStations(stations);
133                          location = (GeoPair) savedInstanceState.getSerializable("location");                          location = (GeoPair) savedInstanceState.getSerializable("location");
                         dialogTitle = savedInstanceState.getString("title");  
                         setTitle(dialogTitle);  
134                  }                  }
135                    
136          }          }
137            protected void setTitle() {
138                    String dialogTitle = getResources().getString(app_name);
139                    switch (listType) {
140                    case ListNearest:
141                            dialogTitle += " - " + getString(stationlist_nearbystations);
142                            break;
143                    case ListSearch:
144                            dialogTitle += " - " + getString(stationlist_search);
145                            break;
146                    case ListFavorites:
147                            dialogTitle += " - " + getString(stationlist_favorites);
148                            break;
149                    default:
150                            dialogTitle = "";//not possible                                
151                    }
152            
153                    setTitle(dialogTitle);
154            }
155            
156            
157    
158    
159      @Override      @Override
# Line 141  public class StationList extends ListAct Line 163  public class StationList extends ListAct
163                  dialog.dismiss();                  dialog.dismiss();
164          outState.putSerializable("stations", (ArrayList<StationBean>) stations);          outState.putSerializable("stations", (ArrayList<StationBean>) stations);
165          outState.putSerializable("location", location);          outState.putSerializable("location", location);
166          outState.putString("title", dialogTitle);          
167      }      }
168                    
169                    
# Line 149  public class StationList extends ListAct Line 171  public class StationList extends ListAct
171          @Override          @Override
172          public boolean onCreateOptionsMenu(Menu menu) {          public boolean onCreateOptionsMenu(Menu menu) {
173                  MenuItem item;                  MenuItem item;
174                                                    
175                  item = menu.add(0, OPTIONS_MAP, 0, "Station map");                  item = menu.add(0, OPTIONS_MAP, 0, getString(stationlist_stationmap));
176                  item.setIcon(android.R.drawable.ic_menu_mapmode);                  item.setIcon(android.R.drawable.ic_menu_mapmode);
177                                    
178                  item = menu.add(0, OPTIONS_GPSINFO, 0, "GPS Info");                  item = menu.add(0, OPTIONS_GPSINFO, 0, getString(stationlist_gpsinfo));
179                  item.setIcon(android.R.drawable.ic_menu_mapmode);                                item.setIcon(android.R.drawable.ic_menu_mapmode);              
180                                    
181                  return true;                  return true;
# Line 168  public class StationList extends ListAct Line 190  public class StationList extends ListAct
190                  case OPTIONS_MAP:                  case OPTIONS_MAP:
191                                                    
192                          Intent intent = new Intent(this,StationMapView.class);                          Intent intent = new Intent(this,StationMapView.class);
                         intent.putExtra("userlocation", location );  
193                                                    
194                          ArrayList<GeoPair> stationPoints = new ArrayList<GeoPair>();                          ArrayList<GeoPair> stationPoints = new ArrayList<GeoPair>();
195                          for (StationBean st : stations ) {                          for (StationBean st : stations ) {
# Line 180  public class StationList extends ListAct Line 201  public class StationList extends ListAct
201                          startActivity(intent);                          startActivity(intent);
202                          break;                          break;
203                  case OPTIONS_GPSINFO:                  case OPTIONS_GPSINFO:
204                          Location loc = locator.getLocation();                          Location loc = locationLookup.getLocation();
205                          StringBuffer message = new StringBuffer();                          StringBuffer message = new StringBuffer();
206                          message.append("Location info:\n");                          message.append( getString(stationlist_locationinfo) ).append(":\n");
207                          message.append("-Obtained by: ").append(loc != null ? loc.getProvider() : "-").append("\n");                          if (loc != null) {
208                          message.append("-Accuracy: ").append(loc != null ? (int)loc.getAccuracy() : "-").append("m\n");                                  message.append( getString(stationlist_obtainedby) ).append( loc.getProvider() ).append("\n");
209                                    message.append( getString(stationlist_accuracy) ).append( (int)loc.getAccuracy()).append("m\n");
210                                    message.append( getString(stationlist_latitude) ).append( (float)loc.getLatitude()).append("\n");
211                                    message.append( getString(stationlist_longitude) ).append( (float)loc.getLongitude() ).append("\n");
212                            } else {
213                                    message.append( getString(stationlist_nolocation) );
214                            }                      
215                            
216                          MessageBox.showMessage(this, message.toString());                          MessageBox.showMessage(this, message.toString());
217                          break;                          break;
218                  default:                  default:
# Line 204  public class StationList extends ListAct Line 231  public class StationList extends ListAct
231    
232    
233          }          }
234            
235            public void showMessageAndClose(String message) {
236                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
237                    builder.setMessage(message)
238                    .setCancelable(false)
239                    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
240                            public void onClick(DialogInterface dialog, int id) {
241                                    dialog.dismiss();
242                                    StationList.this.finish();
243                            }
244                    })
245                    .show();
246            }
247    
248    
249    
# Line 213  public class StationList extends ListAct Line 253  public class StationList extends ListAct
253                  switch (id) {                  switch (id) {
254                  case DLG_PROGRESS:                  case DLG_PROGRESS:
255                          ProgressDialog dlg = new ProgressDialog(this);                          ProgressDialog dlg = new ProgressDialog(this);
256                          dlg.setMessage("Wait for location fix");                          dlg.setMessage( getString(stationlist_waitforlocation) );
257                          dlg.setCancelable(false);                          dlg.setCancelable(false);
258                          return dlg;                                              return dlg;                    
259                  case DLG_STATIONNAME:                  case DLG_STATIONNAME:
# Line 223  public class StationList extends ListAct Line 263  public class StationList extends ListAct
263                                                    
264                          AlertDialog.Builder builder = new AlertDialog.Builder(this);                          AlertDialog.Builder builder = new AlertDialog.Builder(this);
265                                                    
266                          builder.setTitle("Station search");                          builder.setTitle( getString(stationlist_stationsearch) );
267                          builder.setView(rootView);                          builder.setView(rootView);
268                          builder.setCancelable(true);                          builder.setCancelable(true);
269                          builder.setPositiveButton("Search", new DialogInterface.OnClickListener() {                          builder.setPositiveButton( getString(generic_search), new DialogInterface.OnClickListener() {
270                                  public void onClick(DialogInterface dialog, int which) {                                  public void onClick(DialogInterface dialog, int which) {
271                                          EditText et = (EditText) rootView.findViewById(R.id.EditText);                                          EditText et = (EditText) rootView.findViewById(R.id.EditText);
272                                          dialog.dismiss();                                          dialog.dismiss();
273                                          if (et.getText().toString().length() >= 2) {                                          if (et.getText().toString().length() >= 2) {
274                                                  startNameSearch(et.getText().toString());                                                  startNameSearch(et.getText().toString());
275                                          } else {                                          } else {
276                                                  MessageBox.showMessage(StationList.this, "Two characters minimum" );                                                  showMessageAndClose( getString(stationlist_twocharmin) );
277                                          }                                          }
278                                  }                                  }
279                          });                          });
280                          builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {                          builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {
281                                  public void onClick(DialogInterface dialog, int which) {                                  public void onClick(DialogInterface dialog, int which) {
282                                          dialog.dismiss();                                          dialog.dismiss();
283                                            StationList.this.finish(); // Close this Activity
284                                  }                                  }
285                          });                                              });                    
286                          return builder.create();                          return builder.create();
# Line 270  public class StationList extends ListAct Line 311  public class StationList extends ListAct
311                  super.onListItemClick(l, v, position, id);                  super.onListItemClick(l, v, position, id);
312                                                                    
313                  StationBean station = stations.get(position);                  StationBean station = stations.get(position);
   
                 double latitude = station.getLatitude();  
                 double longitude = station.getLongitude();  
   
   
314                                    
315                  Intent intent = new Intent(this, DepartureList.class);                  Intent intent = new Intent(this, DepartureList.class);
316                  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());  
317                  startActivity(intent);                  startActivity(intent);
318          }          }
319    
# Line 290  public class StationList extends ListAct Line 321  public class StationList extends ListAct
321          //          //
322    
323          public void startLookup() {          public void startLookup() {
324                  isRunning = true;                  isRunning = true;              
325                  dialogMessage = "Wait for location fix";                  dialogMessage = getString( stationlist_waitforlocation );
326                  showDialog(DLG_PROGRESS);                  showDialog(DLG_PROGRESS);
327                                    
328                  locator.locateStations();                  locationLookup.locateStations();
329                  stationsFetched.sendEmptyMessageDelayed(LOCATIONFIXTIMEOUT, 20000);                  stationsFetched.sendEmptyMessageDelayed(LOCATIONFIXTIMEOUT, 20000);
330          }          }
331                    
332          void startNameSearch(String name) {          void startNameSearch(String name) {
333                  dialogMessage = "Finding stations by name";                  dialogMessage = getString( stationlist_findbyname );
334                  showDialog(DLG_PROGRESS);                  showDialog(DLG_PROGRESS);
335    
336                  findStationsTask = new FindStationsTask();                  findStationsTask = new FindStationsTask();
337                  findStationsTask.searchByName(name, locator.getLocation());                  findStationsTask.searchByName(name);
338                  findStationsTask.execute();                  findStationsTask.execute();
339                                    
340          }          }
# Line 311  public class StationList extends ListAct Line 342  public class StationList extends ListAct
342          public void startFavoriteLookup() {          public void startFavoriteLookup() {
343                                    
344                  if (favorites.size() > 0) {                  if (favorites.size() > 0) {
345                          dialogMessage = "Loading favorites";                          dialogMessage = getString( stationlist_loadfavorites );
346                          showDialog(DLG_PROGRESS);                          showDialog(DLG_PROGRESS);
347    
348                          findStationsTask = new FindStationsTask();                          findStationsTask = new FindStationsTask();
349                          findStationsTask.searchByIds(favorites.toString(), locator.getLocation());                          findStationsTask.searchByIds( favorites.toString() );
350                          findStationsTask.execute();                          findStationsTask.execute();
351                  } else {                  } else {
352                          MessageBox.showMessage(this, "Favorite list is empty");                          showMessageAndClose( getString( stationlist_nofavorites ) );
353                  }                  }
354          }          }
355    
# Line 326  public class StationList extends ListAct Line 357  public class StationList extends ListAct
357                    
358          void startLocatorTask()          void startLocatorTask()
359          {          {
360                  dialogMessage = "Finding nearby stations";                  dialogMessage = getString( stationlist_findingnearby );
361                  showDialog(DLG_PROGRESS);                  showDialog(DLG_PROGRESS);
362                                    
363                  findStationsTask = new FindStationsTask();                  findStationsTask = new FindStationsTask();
364                  findStationsTask.searchByLocation( locator.getLocation() );                  findStationsTask.searchByLocation( locationLookup.getLocation() );
365                  findStationsTask.execute();                      findStationsTask.execute();    
366          }          }
           
   
         String lookupAddress(double latitude, double longitude) {  
367                                    
                 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();  
         }  
           
368                    
369          ////////////////////////////////////////////////////////////////////////////          ////////////////////////////////////////////////////////////////////////////
370          // Inner classes          // Inner classes
# Line 374  public class StationList extends ListAct Line 378  public class StationList extends ListAct
378                                  dismissDialog(DLG_PROGRESS);                                  dismissDialog(DLG_PROGRESS);
379                                                                    
380                                  startLocatorTask();                                  startLocatorTask();
381                                  location = GeoPair.fromLocation( locator.getLocation() );                                  location = GeoPair.fromLocation( locationLookup.getLocation() );
382                                                                    
383                                  break;                                  break;
384    
385                          case NOPROVIDER:                          case NOPROVIDER:
386                                  dismissDialog(DLG_PROGRESS);                                  dismissDialog(DLG_PROGRESS);
387                                  MessageBox.showMessage(StationList.this,"No location provider enabled. Plase enable gps.");                                  MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider) );
388                                  break;                                  break;
389                          case LOCATIONFIXTIMEOUT:                                                          case LOCATIONFIXTIMEOUT:                                
390                                  if (isRunning) {                                  if (isRunning) {
391                                          locator.stopSearch();                                          locationLookup.stopSearch();
392                                          if (locator.hasLocation()) {                                          if (locationLookup.hasLocation()) {
393                                                  stationsFetched.sendEmptyMessage( GOTLOCATION );                                                  stationsFetched.sendEmptyMessage( GOTLOCATION );
394                                          } else {                                                                                          } else {                                                
395                                                  dismissDialog(DLG_PROGRESS);                                                  dismissDialog(DLG_PROGRESS);
396                                                                                                    
397                                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                                                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                
398                                                  builder.setMessage("Location fix timed out");                                                  builder.setMessage(  getString( stationlist_gpstimeout) );
399                                                  builder.setCancelable(true);                                                  builder.setCancelable(true);
400                                                  builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() {                                                  builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {
401                                                          public void onClick(DialogInterface dialog, int id) {                                                          public void onClick(DialogInterface dialog, int id) {
402                                                                  dialog.dismiss();                                                                  dialog.dismiss();
403                                                                  startLookup();                                                                  startLookup();
404                                                                                                                                    
405                                                          }                                                          }
406                                                  });                                                  });
407                                                  builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {                                                  builder.setNegativeButton( getString(generic_cancel), new DialogInterface.OnClickListener() {
408                                                          public void onClick(DialogInterface dialog, int id) {                                                          public void onClick(DialogInterface dialog, int id) {
409                                                                  dialog.dismiss();                                                                  dialog.dismiss();
410                                                          }                                                                                                                }                                                      
# Line 424  public class StationList extends ListAct Line 428  public class StationList extends ListAct
428                  Location loc;                  Location loc;
429                  String ids;                  String ids;
430                                    
431                  public void searchByName(String n, Location l) {                  public void searchByName(String n) {
432                                                    
433                          method = LookupMethod.ByName;                          method = LookupMethod.ByName;
                         loc = l;  
434                          name = n;                          name = n;
435                  }                  }
436                                    
# Line 436  public class StationList extends ListAct Line 439  public class StationList extends ListAct
439                          loc = l;                          loc = l;
440                  }                  }
441                                    
442                  public void searchByIds(String id, Location l) {                  public void searchByIds(String id) {
443                                                    
444                          method = LookupMethod.ByList;                          method = LookupMethod.ByList;
                         loc = l;  
445                          ids = id;                          ids = id;
446                  }                  }
447                                    
# Line 469  public class StationList extends ListAct Line 471  public class StationList extends ListAct
471                          }                          }
472                                                    
473                                                    
                         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);  
                                         }  
                                 }  
   
                         }                                                
                           
474                          return null;                          return null;
475                  }                  }
476    
# Line 497  public class StationList extends ListAct Line 479  public class StationList extends ListAct
479                          super.onPostExecute(result);                          super.onPostExecute(result);
480                          dialog.dismiss();                          dialog.dismiss();
481                                                    
                         //set title  
                         switch (method) {  
                         case ByLocation:  
                                 dialogTitle = "Traininfo DK - Nearby stations";  
                                 break;  
                         case ByName:  
                                 dialogTitle = "Traininfo DK - Search";  
                                 break;  
                         case ByList:  
                                 dialogTitle = "Traininfo DK - Favorites";  
                                 break;  
                         default:  
                                 dialogTitle = "";//not possible                                  
                         }                                
                           
                         StationList.this.setTitle(dialogTitle);  
                         //set title end  
482                                                    
483                          if (success) {                                                    if (success) {                          
484                                  if (stationProvider.getStations().size() == 0)                                  if (stationProvider.getStations().size() == 0) {
485                                          MessageBox.showMessage(StationList.this, "No stations found!"); // this should not be possible !?!                                          showMessageAndClose(getString(stationlist_nostations));
486                                    }
487                                  stations = stationProvider.getStations();                                  stations = stationProvider.getStations();
488                                  adapter.setStations( stations );                                                                  adapter.setStations( stations );                                
489                                                                    
490                          } else { //communication or parse errors                          } else { //communication or parse errors
491                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                
492                                  builder.setMessage("Error on finding nearby stations");                                  builder.setMessage(getString(stationlist_nearbyerror));                        
493                                  builder.setCancelable(true);                                  builder.setCancelable(true);
494                                  builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() {                                  builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {
495                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
496                                                  dialog.dismiss();                                                  dialog.dismiss();
497                                                                                                    
# Line 537  public class StationList extends ListAct Line 503  public class StationList extends ListAct
503                                                  });                                                  });
504                                          }                                          }
505                                  });                                  });
506                                  builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {
507                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
508                                                  dialog.dismiss();                                                  dialog.dismiss();
509                                          }                                                                                                }                                                      
# Line 563  public class StationList extends ListAct Line 529  public class StationList extends ListAct
529                          int stationID = stations.get(selectedPosition).getId();                          int stationID = stations.get(selectedPosition).getId();
530    
531                          if (!favorites.contains(stationID)) {                          if (!favorites.contains(stationID)) {
532                                  menu.add(0, FAVORITES_ADD, 0, "Add to favorites");                                  menu.add(0, FAVORITES_ADD, 0, getString(stationlist_addfavorite) );
533                          } else {                          } else {
534                                  menu.add(0, FAVORITES_REMOVE, 0, "Remove from favorites");                                  menu.add(0, FAVORITES_REMOVE, 0, getString(stationlist_removefavorite) );
535                          }                          }
536                                                    
537                  }                  }
# Line 576  public class StationList extends ListAct Line 542  public class StationList extends ListAct
542                          int stationID = sb.getId();                          int stationID = sb.getId();
543                          if (item.getItemId() == FAVORITES_ADD) {                          if (item.getItemId() == FAVORITES_ADD) {
544                                  favorites.add(stationID);                                  favorites.add(stationID);
545                                  Toast.makeText(StationList.this, "Station added", Toast.LENGTH_SHORT).show();                                  Toast.makeText(StationList.this, getString(stationlist_stationadded), Toast.LENGTH_SHORT).show();
546                          } else {                          } else {
547                                                                    
548                                  favorites.remove(stationID);                                  favorites.remove(stationID);
549                                  Toast.makeText(StationList.this, "Station removed", Toast.LENGTH_SHORT).show();                                  Toast.makeText(StationList.this, getString(stationlist_stationremoved), Toast.LENGTH_SHORT).show();
550                                                                    
551                                                                    
552                                  if (listType.equals( WelcomeScreen.ListType.ListFavorites) ) {                                  if (listType.equals( WelcomeScreen.ListType.ListFavorites) ) {

Legend:
Removed from v.481  
changed lines
  Added in v.579

  ViewVC Help
Powered by ViewVC 1.1.20