/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/TrainInfoList.java
ViewVC logotype

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/TrainInfoList.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 316 by torben, Fri Sep 11 08:48:18 2009 UTC revision 317 by torben, Fri Sep 11 09:12:45 2009 UTC
# Line 163  public class TrainInfoList extends ListA Line 163  public class TrainInfoList extends ListA
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    
170                    String lookupAddress(double latitude, double longitude) {
171                    
172                    Geocoder coder = new Geocoder(this, new Locale("da"));
173                    StringBuilder sb = new StringBuilder();
174                    Log.i("lookupaddr", "" + latitude + "/" + longitude);
175                    try {
176                            List<Address> addressList = coder.getFromLocation(latitude, longitude, 1);
177                            Address addr = addressList.get(0);
178                            
179                            
180                            int max = addr.getMaxAddressLineIndex();
181                            for (int i=0; i<max; i++) {
182                                    if (i>0)
183                                            sb.append(", ");
184                                    
185                                    sb.append(addr.getAddressLine(i));
186                            }
187                            
188                            
189                    } catch (Exception e) {
190                            Log.e("DepartureList", "geocoder failed", e);
191                    }
192                    
193                    return sb.toString();
194            }
195                    
196          class LocatorTask extends AsyncTask<Void,Void,Void> {          class LocatorTask extends AsyncTask<Void,Void,Void> {
197                  @Override                  @Override
# Line 179  public class TrainInfoList extends ListA Line 204  public class TrainInfoList extends ListA
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    

Legend:
Removed from v.316  
changed lines
  Added in v.317

  ViewVC Help
Powered by ViewVC 1.1.20