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

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

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

revision 1261 by torben, Mon Apr 4 22:14:40 2011 UTC revision 1432 by torben, Tue May 3 12:35:34 2011 UTC
# Line 31  import dk.thoerup.android.traininfo.comm Line 31  import dk.thoerup.android.traininfo.comm
31  import dk.thoerup.android.traininfo.common.DepartureEntry;  import dk.thoerup.android.traininfo.common.DepartureEntry;
32  import dk.thoerup.android.traininfo.common.MetroBean;  import dk.thoerup.android.traininfo.common.MetroBean;
33  import dk.thoerup.android.traininfo.common.MetroBean.MetroEntry;  import dk.thoerup.android.traininfo.common.MetroBean.MetroEntry;
34  import dk.thoerup.android.traininfo.common.StationBean.StationEntry;  import dk.thoerup.android.traininfo.common.StationEntry;
35  import dk.thoerup.traininfo.provider.DepartureProvider;  import dk.thoerup.traininfo.provider.DepartureProvider;
36  import dk.thoerup.traininfo.provider.MetroProvider;  import dk.thoerup.traininfo.provider.MetroProvider;
37  import dk.thoerup.traininfo.provider.ProviderFactory;  import dk.thoerup.traininfo.provider.ProviderFactory;
# Line 364  public class DepartureList extends ListA Line 364  public class DepartureList extends ListA
364                  boolean res;                  boolean res;
365                  switch(item.getItemId()) {                  switch(item.getItemId()) {
366                  case MENU_MAP:                  case MENU_MAP:
367                          Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude() + "?z=16");                          try {
368                          startActivity( new Intent(Intent.ACTION_VIEW, uri));                                  Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude() + "?z=16");
369                                    startActivity( new Intent(Intent.ACTION_VIEW, uri));
370                            } catch (ActivityNotFoundException anfe) {
371                                     Toast.makeText(this, "Could not launch google maps", Toast.LENGTH_LONG).show();
372                            }
373                          res = true;                          res = true;
374                          break;                          break;
375                  case MENU_NOTIFICATIONS:                  case MENU_NOTIFICATIONS:
# Line 429  public class DepartureList extends ListA Line 433  public class DepartureList extends ListA
433                                                    
434                                                    
435                          pgDialog.dismiss();                          pgDialog.dismiss();
436                            
437                          if (departures != null) {                          if (departures != null && departures.errorCode == null) {
438                                  commFailCounter = 0;                                  commFailCounter = 0;
439                                  DepartureList.this.getListView().setVisibility(View.GONE); //Experimental, inspired by http://osdir.com/ml/Android-Developers/2010-04/msg01198.html                                  DepartureList.this.getListView().setVisibility(View.GONE); //Experimental, inspired by http://osdir.com/ml/Android-Developers/2010-04/msg01198.html
440                                  adapter.setDepartures(departures.entries);                                  adapter.setDepartures(departures.entries);
# Line 453  public class DepartureList extends ListA Line 457  public class DepartureList extends ListA
457                                  }                                                                }                              
458                                                                    
459                                  if (departures.entries.size() == 0) {                                  if (departures.entries.size() == 0) {
460                                          MessageBox.showMessage(DepartureList.this, "No departures found", true);                                          int msgId = (arrival==false) ? R.string.departurelist_nodepartures : R.string.departurelist_noarrivals;
461                                            MessageBox.showMessage(DepartureList.this, getString(msgId), false);
462                                  }                                  }
463                          } else { // communication or parse error                          } else { // communication or parse error
464                                  commFailCounter++;                                  commFailCounter++;
465                                  AlertDialog.Builder builder = new AlertDialog.Builder(DepartureList.this);                                                                                AlertDialog.Builder builder = new AlertDialog.Builder(DepartureList.this);
466                                  builder.setMessage("Error finding departures");                                  
467                                    if (departures != null && departures.errorCode != null ) { //got an error xml back
468                                            commFailCounter = 10;
469                                            builder.setMessage( getString(R.string.no_backend) );
470                                    } else {                                        
471                                            builder.setMessage( getString(R.string.departurelist_fetcherror) );            
472                                    }
473                                  builder.setCancelable(true);                                  builder.setCancelable(true);
474                                    
475                                  if (commFailCounter < 3) {                                  if (commFailCounter < 3) {
476                                          builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {                                          builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {
477                                                  public void onClick(DialogInterface dialog, int id) {                                                  public void onClick(DialogInterface dialog, int id) {
# Line 476  public class DepartureList extends ListA Line 488  public class DepartureList extends ListA
488                                          }                                                                                                }                                                      
489                                  });                                  });
490                                                                    
491                                  try {                                  try { //TODO: is this still necessary after the 0.9.4.1 fix ?
492                                          builder.show();                                          builder.show();
493                                  } catch (android.view.WindowManager.BadTokenException e) {                                                                        } catch (android.view.WindowManager.BadTokenException e) {                                      
494                                          Log.i("DepartureList", "BadTokenException"); // this can happen if the user switched away from this activity, while doInBackground was running                                          Log.i("DepartureList", "BadTokenException"); // this can happen if the user switched away from this activity, while doInBackground was running
# Line 582  public class DepartureList extends ListA Line 594  public class DepartureList extends ListA
594                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {
595                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
596                                                  dialog.dismiss();                                                  dialog.dismiss();
597                                                  DepartureList.this.finish();                                                  DepartureList.this.finish(); //TODO: should we really close the activity ??
598                                          }                                                                                                }                                                      
599                                  });                                  });
600                                                                    
601                                  try {                                  try { //TODO: is this still necessary after the 0.9.4.1 fix ?
602                                          builder.show();                                          builder.show();
603                                  } catch (android.view.WindowManager.BadTokenException e) {                                                                        } catch (android.view.WindowManager.BadTokenException e) {                                      
604                                          Log.i("DepartureList", "BadTokenException"); // this can happen if the user switched away from this activity, while doInBackground was running                                          Log.i("DepartureList", "BadTokenException"); // this can happen if the user switched away from this activity, while doInBackground was running

Legend:
Removed from v.1261  
changed lines
  Added in v.1432

  ViewVC Help
Powered by ViewVC 1.1.20