/[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 713 by torben, Fri May 7 15:13:07 2010 UTC revision 917 by torben, Sat Jun 26 10:50:34 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 69  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 111  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 177  public class StationList extends ListAct Line 181  public class StationList extends ListAct
181                          Log.e("StationList", "dismissDialog failed", e);                          Log.e("StationList", "dismissDialog failed", e);
182                  }                  }
183          }          }
184            public void dismissDialogSafe(Dialog dlg) {
185                    try {
186                            dlg.dismiss();
187                    } catch (Exception e) {
188                            Log.e("StationList", "dismissDialog failed", e);
189                    }
190            }
191                    
192          public void builderShowSafe(AlertDialog.Builder builder) {          public void builderShowSafe(AlertDialog.Builder builder) {
193                  try {                  try {
# Line 247  public class StationList extends ListAct Line 258  public class StationList extends ListAct
258                                  message.append( getString(stationlist_nolocation) );                                  message.append( getString(stationlist_nolocation) );
259                          }                                                }                      
260                                                    
261                          MessageBox.showMessage(this, message.toString());                          MessageBox.showMessage(this, message.toString(), false);
262                          break;                          break;
263                  default:                  default:
264                          retval = super.onOptionsItemSelected(item);                          retval = super.onOptionsItemSelected(item);
# Line 347  public class StationList extends ListAct Line 358  public class StationList extends ListAct
358                                                                    
359                  StationBean station = stations.get(position);                  StationBean station = stations.get(position);
360                                    
361                  Intent intent = new Intent(this, DepartureList.class);                  if (isLaunchedforShortcut == true) {
362                  intent.putExtra("stationbean", station);                          Intent i = new Intent();
363                  startActivity(intent);                          i.putExtra("station", station);
364                            setResult(Activity.RESULT_OK, i);
365                            finish();
366                    } else {                
367                            Intent intent = new Intent(this, DepartureList.class);
368                            intent.putExtra("stationbean", station);
369                            startActivity(intent);
370                    }
371          }          }
372    
373          /////////////////////////////////////////////////////////////          /////////////////////////////////////////////////////////////
# Line 419  public class StationList extends ListAct Line 437  public class StationList extends ListAct
437    
438                          case NOPROVIDER:                          case NOPROVIDER:
439                                  dismissDialogSafe(DLG_PROGRESS);                                  dismissDialogSafe(DLG_PROGRESS);
440                                  MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider) );                                  MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider), true );
441                                    //StationList.this.finish();
442                                  break;                                  break;
443                          case LOCATIONFIXTIMEOUT:                                                          case LOCATIONFIXTIMEOUT:                                
444                                  if (isRunning) {                                  if (isRunning) {
# Line 512  public class StationList extends ListAct Line 531  public class StationList extends ListAct
531                  @Override                  @Override
532                  protected void onPostExecute(Void result) {                  protected void onPostExecute(Void result) {
533                          super.onPostExecute(result);                          super.onPostExecute(result);
534                          dialog.dismiss();                          dismissDialogSafe(dialog);
535                                                    
536                                                    
537                          if (success) {                                                    if (success) {                          
# Line 520  public class StationList extends ListAct Line 539  public class StationList extends ListAct
539                                          showMessageAndClose(getString(stationlist_nostations));                                          showMessageAndClose(getString(stationlist_nostations));
540                                  }                                  }
541                                  stations = stationProvider.getStations();                                  stations = stationProvider.getStations();
542    
543                                    StationList.this.getListView().invalidateViews();
544                                  adapter.setStations( stations );                                                                  adapter.setStations( stations );                                
545                                                                    
546                                    
547                          } else { //communication or parse errors                          } else { //communication or parse errors
548                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                
549                                  builder.setMessage(getString(stationlist_nearbyerror));                                                          builder.setMessage(getString(stationlist_fetcherror));                          
550                                  builder.setCancelable(true);                                  builder.setCancelable(true);
551                                  builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {                                  builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {
552                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
# Line 564  public class StationList extends ListAct Line 586  public class StationList extends ListAct
586                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {
587                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
588                                                  dialog.dismiss();                                                  dialog.dismiss();
589                                                    StationList.this.finish();
590                                          }                                                                                                }                                                      
591                                  });                                  });
592                                                                    

Legend:
Removed from v.713  
changed lines
  Added in v.917

  ViewVC Help
Powered by ViewVC 1.1.20