--- 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 11:21:30 241 @@ -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); @@ -85,6 +89,7 @@ switch (msg.what) { case GOTLOCATION: dialog.setMessage("Finding nearby stations"); + locatorTask.execute(); break; case GOTSTATIONLIST: dialog.dismiss(); @@ -141,4 +146,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