--- android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/09/18 07:18:59 1078 +++ android/TrainInfo/src/dk/thoerup/traininfo/StationList.java 2010/09/28 14:58:45 1142 @@ -30,10 +30,10 @@ import static dk.thoerup.traininfo.R.string.stationlist_stationsearch; import static dk.thoerup.traininfo.R.string.stationlist_twocharmin; import static dk.thoerup.traininfo.R.string.stationlist_waitforlocation; +import static dk.thoerup.traininfo.R.string.stationlist_satellitecount; import java.util.ArrayList; - import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -48,6 +48,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; +import android.util.Log; import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.Menu; @@ -69,10 +70,14 @@ import dk.thoerup.traininfo.util.MessageBox; public class StationList extends ListActivity { - public static final int GOTLOCATION = 1001; - public static final int GOTSTATIONLIST = 1002; - public static final int NOPROVIDER = 1003; - public static final int LOCATIONFIXTIMEOUT = 1004; + public enum LookupStates { + GOTLOCATION, + GOTSTATIONLIST, + NOPROVIDER, + LOCATIONFIXTIMEOUT, + GPS_SAT_COUNT + } + public static final int OPTIONS_MAP = 2003; public static final int OPTIONS_GPSINFO = 2004; @@ -391,7 +396,7 @@ showDialog(DLG_PROGRESS); locationLookup.locateStations(); - stationsFetched.sendEmptyMessageDelayed(LOCATIONFIXTIMEOUT, GPS_TIMEOUT_MS); + stationsFetched.sendEmptyMessageDelayed(LookupStates.LOCATIONFIXTIMEOUT.ordinal(), GPS_TIMEOUT_MS); } void startNameSearch(String name) { @@ -437,8 +442,11 @@ class StationsFetchedHandler extends Handler { @Override public void handleMessage(Message msg) { + Log.e("Handler", "WHAT:" + msg.what); + + LookupStates state = LookupStates.values()[msg.what]; - switch (msg.what) { + switch (state) { case GOTLOCATION: dismissDialog(DLG_PROGRESS); @@ -452,11 +460,16 @@ MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider), true ); //StationList.this.finish(); break; + case GPS_SAT_COUNT: + int count = msg.arg1; + String dialogMessage = getString( stationlist_waitforlocation ) + "\n" + getString( stationlist_satellitecount ) + ": " + count; + dialog.setMessage( dialogMessage ); + return; //abort immediately case LOCATIONFIXTIMEOUT: if (isRunning) { locationLookup.stopSearch(); if (locationLookup.hasLocation()) { - stationsFetched.sendEmptyMessage( GOTLOCATION ); + stationsFetched.sendEmptyMessage( LookupStates.GOTLOCATION.ordinal() ); } else { dismissDialog(DLG_PROGRESS);