44 |
super.onCreate(savedInstanceState); |
super.onCreate(savedInstanceState); |
45 |
setContentView(R.layout.main); |
setContentView(R.layout.main); |
46 |
|
|
47 |
//StationLocator.removeMockLocation(this); |
StationLocator.removeMockLocation(this); |
48 |
StationLocator.injectMockLocation(this); |
//StationLocator.injectMockLocation(this); |
49 |
|
|
50 |
adapter = new StationListAdapter(this); |
adapter = new StationListAdapter(this); |
51 |
setListAdapter(adapter); |
setListAdapter(adapter); |
154 |
|
|
155 |
double latitude = station.getLatitude(); |
double latitude = station.getLatitude(); |
156 |
double longitude = station.getLongitude(); |
double longitude = station.getLongitude(); |
|
String addr = station.getAddress(); |
|
157 |
|
|
|
if (addr == null || addr.trim().equals("") ) |
|
|
addr = lookupAddress(latitude, longitude); |
|
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", addr); |
|
162 |
intent.putExtra("distance", station.getDistance()); |
intent.putExtra("distance", station.getDistance()); |
163 |
intent.putExtra("latitude", latitude); |
intent.putExtra("latitude", latitude); |
164 |
intent.putExtra("longitude", longitude); |
intent.putExtra("longitude", longitude); |
165 |
intent.putExtra("stationid", station.getId()); |
intent.putExtra("stationid", station.getId()); |
166 |
|
intent.putExtra("address", station.getAddress()); |
167 |
startActivity(intent); |
startActivity(intent); |
168 |
} |
} |
169 |
|
|
193 |
return sb.toString(); |
return sb.toString(); |
194 |
} |
} |
195 |
|
|
|
|
|
196 |
class LocatorTask extends AsyncTask<Void,Void,Void> { |
class LocatorTask extends AsyncTask<Void,Void,Void> { |
197 |
@Override |
@Override |
198 |
protected void onPreExecute() { |
protected void onPreExecute() { |
204 |
protected Void doInBackground(Void... params) { |
protected Void doInBackground(Void... params) { |
205 |
locator.findNearestStations(); |
locator.findNearestStations(); |
206 |
|
|
207 |
|
List<StationBean> stations = locator.getStations(); |
208 |
|
for (StationBean station : stations) { |
209 |
|
String addr = lookupAddress(station.getLatitude(), station.getLongitude()); |
210 |
|
station.setAddress(addr); |
211 |
|
} |
212 |
|
|
213 |
return null; |
return null; |
214 |
} |
} |
215 |
|
|