/[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 919 by torben, Sat Jun 26 11:06:12 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 135  public class StationList extends ListAct Line 139  public class StationList extends ListAct
139                  }                  }
140                                    
141          }          }
142            
143    
144            @Override
145            protected void onDestroy() {
146                    super.onDestroy();
147                    
148                    if (findStationsTask != null) {
149                            findStationsTask.cancel(true);
150                    }
151                    if (locationLookup != null) {
152                            locationLookup.stopSearch();
153                    }
154                    isRunning = false;
155            }
156    
157            
158          protected void setTitle() {          protected void setTitle() {
159                  String dialogTitle = getResources().getString(app_name);                  String dialogTitle = getResources().getString(app_name);
160                  switch (listType) {                  switch (listType) {
# Line 177  public class StationList extends ListAct Line 197  public class StationList extends ListAct
197                          Log.e("StationList", "dismissDialog failed", e);                          Log.e("StationList", "dismissDialog failed", e);
198                  }                  }
199          }          }
200            public void dismissDialogSafe(Dialog dlg) {
201                    try {
202                            dlg.dismiss();
203                    } catch (Exception e) {
204                            Log.e("StationList", "dismissDialog failed", e);
205                    }
206            }
207                    
208          public void builderShowSafe(AlertDialog.Builder builder) {          public void builderShowSafe(AlertDialog.Builder builder) {
209                  try {                  try {
# Line 247  public class StationList extends ListAct Line 274  public class StationList extends ListAct
274                                  message.append( getString(stationlist_nolocation) );                                  message.append( getString(stationlist_nolocation) );
275                          }                                                }                      
276                                                    
277                          MessageBox.showMessage(this, message.toString());                          MessageBox.showMessage(this, message.toString(), false);
278                          break;                          break;
279                  default:                  default:
280                          retval = super.onOptionsItemSelected(item);                          retval = super.onOptionsItemSelected(item);
# Line 347  public class StationList extends ListAct Line 374  public class StationList extends ListAct
374                                                                    
375                  StationBean station = stations.get(position);                  StationBean station = stations.get(position);
376                                    
377                  Intent intent = new Intent(this, DepartureList.class);                  if (isLaunchedforShortcut == true) {
378                  intent.putExtra("stationbean", station);                          Intent i = new Intent();
379                  startActivity(intent);                          i.putExtra("station", station);
380                            setResult(Activity.RESULT_OK, i);
381                            finish();
382                    } else {                
383                            Intent intent = new Intent(this, DepartureList.class);
384                            intent.putExtra("stationbean", station);
385                            startActivity(intent);
386                    }
387          }          }
388    
389          /////////////////////////////////////////////////////////////          /////////////////////////////////////////////////////////////
# Line 419  public class StationList extends ListAct Line 453  public class StationList extends ListAct
453    
454                          case NOPROVIDER:                          case NOPROVIDER:
455                                  dismissDialogSafe(DLG_PROGRESS);                                  dismissDialogSafe(DLG_PROGRESS);
456                                  MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider) );                                  MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider), true );
457                                    //StationList.this.finish();
458                                  break;                                  break;
459                          case LOCATIONFIXTIMEOUT:                                                          case LOCATIONFIXTIMEOUT:                                
460                                  if (isRunning) {                                  if (isRunning) {
# Line 512  public class StationList extends ListAct Line 547  public class StationList extends ListAct
547                  @Override                  @Override
548                  protected void onPostExecute(Void result) {                  protected void onPostExecute(Void result) {
549                          super.onPostExecute(result);                          super.onPostExecute(result);
550                          dialog.dismiss();                          dismissDialogSafe(dialog);
551                                                    
552                                                    
553                          if (success) {                                                    if (success) {                          
# Line 520  public class StationList extends ListAct Line 555  public class StationList extends ListAct
555                                          showMessageAndClose(getString(stationlist_nostations));                                          showMessageAndClose(getString(stationlist_nostations));
556                                  }                                  }
557                                  stations = stationProvider.getStations();                                  stations = stationProvider.getStations();
558    
559                                    StationList.this.getListView().invalidateViews();
560                                  adapter.setStations( stations );                                                                  adapter.setStations( stations );                                
561                                                                    
562                                    
563                          } else { //communication or parse errors                          } else { //communication or parse errors
564                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                                                  AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this);                                                
565                                  builder.setMessage(getString(stationlist_nearbyerror));                                                          builder.setMessage(getString(stationlist_fetcherror));                          
566                                  builder.setCancelable(true);                                  builder.setCancelable(true);
567                                  builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {                                  builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {
568                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
# Line 564  public class StationList extends ListAct Line 602  public class StationList extends ListAct
602                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {
603                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
604                                                  dialog.dismiss();                                                  dialog.dismiss();
605                                                    StationList.this.finish();
606                                          }                                                                                                }                                                      
607                                  });                                  });
608                                                                    

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

  ViewVC Help
Powered by ViewVC 1.1.20