2 |
|
|
3 |
import java.util.ArrayList; |
import java.util.ArrayList; |
4 |
import java.util.List; |
import java.util.List; |
5 |
|
import java.util.Locale; |
6 |
|
|
7 |
import android.app.Dialog; |
import android.app.Dialog; |
8 |
import android.app.ListActivity; |
import android.app.ListActivity; |
9 |
import android.app.ProgressDialog; |
import android.app.ProgressDialog; |
10 |
import android.content.Intent; |
import android.content.Intent; |
11 |
|
import android.location.Address; |
12 |
|
import android.location.Geocoder; |
13 |
import android.os.AsyncTask; |
import android.os.AsyncTask; |
14 |
import android.os.Bundle; |
import android.os.Bundle; |
15 |
import android.os.Handler; |
import android.os.Handler; |
16 |
import android.os.Message; |
import android.os.Message; |
17 |
|
import android.util.Log; |
18 |
import android.view.View; |
import android.view.View; |
19 |
import android.widget.ListView; |
import android.widget.ListView; |
20 |
import dk.thoerup.traininfo.util.MessageBox; |
import dk.thoerup.traininfo.util.MessageBox; |
127 |
dialog.dismiss(); |
dialog.dismiss(); |
128 |
if (isRunning) { |
if (isRunning) { |
129 |
locator.abortLocationListener(); |
locator.abortLocationListener(); |
130 |
MessageBox.showMessage(TrainInfoList.this,"GPS fix timed out"); |
if (locator.hasLocation()) { |
131 |
|
msg.what = GOTLOCATION; |
132 |
|
handleMessage( msg ); // ToDo: ugly recursive call !!! |
133 |
|
} else { |
134 |
|
MessageBox.showMessage(TrainInfoList.this,"GPS fix timed out"); |
135 |
|
} |
136 |
} |
} |
137 |
break; |
break; |
138 |
case LOOKUPSTATIONFAILED: |
case LOOKUPSTATIONFAILED: |
149 |
@Override |
@Override |
150 |
protected void onListItemClick(ListView l, View v, int position, long id) { |
protected void onListItemClick(ListView l, View v, int position, long id) { |
151 |
super.onListItemClick(l, v, position, id); |
super.onListItemClick(l, v, position, id); |
152 |
|
|
|
|
|
153 |
StationBean station = stations.get(position); |
StationBean station = stations.get(position); |
154 |
|
|
155 |
|
double latitude = station.getLatitude(); |
156 |
|
double longitude = station.getLongitude(); |
157 |
|
|
158 |
|
|
159 |
|
|
160 |
Intent intent = new Intent(this, DepartureList.class); |
Intent intent = new Intent(this, DepartureList.class); |
161 |
intent.putExtra("name", station.getName()); |
intent.putExtra("name", station.getName()); |
|
intent.putExtra("address", station.getAddress()); |
|
162 |
intent.putExtra("distance", station.getDistance()); |
intent.putExtra("distance", station.getDistance()); |
163 |
intent.putExtra("latitude", station.getLatitude()); |
intent.putExtra("latitude", latitude); |
164 |
intent.putExtra("longitude", station.getLongitude()); |
intent.putExtra("longitude", longitude); |
165 |
|
intent.putExtra("stationid", station.getId()); |
166 |
startActivity(intent); |
startActivity(intent); |
167 |
} |
} |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
class LocatorTask extends AsyncTask<Void,Void,Void> { |
class LocatorTask extends AsyncTask<Void,Void,Void> { |
172 |
@Override |
@Override |
173 |
protected void onPreExecute() { |
protected void onPreExecute() { |