--- android/TrainInfo/src/dk/thoerup/traininfo/TrainInfoList.java 2009/08/09 09:20:45 240 +++ android/TrainInfo/src/dk/thoerup/traininfo/TrainInfoList.java 2009/08/09 12:12:33 243 @@ -6,6 +6,7 @@ import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.Intent; +import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -24,6 +25,7 @@ /** Called when the activity is first created. */ ProgressDialog dialog; StationLocator locator = null; + LocatorTask locatorTask = new LocatorTask(); boolean isRunning; @@ -33,6 +35,8 @@ super.onCreate(savedInstanceState); setContentView(R.layout.main); + //StationLocator.injectMockLocation(this); + adapter = new StationListAdapter(this); setListAdapter(adapter); @@ -41,6 +45,13 @@ startLookup(); } + @Override + public void onSaveInstanceState(Bundle outState) + { + if (dialog.isShowing()) + dialog.dismiss(); + } + @Override @@ -85,6 +96,7 @@ switch (msg.what) { case GOTLOCATION: dialog.setMessage("Finding nearby stations"); + locatorTask.execute(); break; case GOTSTATIONLIST: dialog.dismiss(); @@ -92,7 +104,7 @@ break; case NOPROVIDER: dialog.dismiss(); - showMessageBox("No Location provider enabled. Plase enabled gps."); + showMessageBox("No location provider enabled. Plase enable gps."); break; case FIXTIMEOUT: dialog.dismiss(); @@ -141,4 +153,22 @@ .show(); } + + class LocatorTask extends AsyncTask { + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + @Override + protected Void doInBackground(Void... params) { + locator.findNearestStations(); + return null; + } + + @Override + protected void onPostExecute(Void result) { + super.onPostExecute(result); + } + } } \ No newline at end of file