/[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 315 by torben, Thu Sep 10 19:11:48 2009 UTC revision 316 by torben, Fri Sep 11 08:48:18 2009 UTC
# Line 154  public class TrainInfoList extends ListA Line 154  public class TrainInfoList extends ListA
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);
# Line 170  public class TrainInfoList extends ListA Line 166  public class TrainInfoList extends ListA
166                  startActivity(intent);                  startActivity(intent);
167          }          }
168    
         String lookupAddress(double latitude, double longitude) {  
                   
                 Geocoder coder = new Geocoder(this, new Locale("da"));  
                 StringBuilder sb = new StringBuilder();  
                 Log.i("lookupaddr", "" + latitude + "/" + longitude);  
                 try {  
                         List<Address> addressList = coder.getFromLocation(latitude, longitude, 1);  
                         Address addr = addressList.get(0);  
                           
                           
                         int max = addr.getMaxAddressLineIndex();  
                         for (int i=0; i<max; i++) {  
                                 if (i>0)  
                                         sb.append(", ");  
                                   
                                 sb.append(addr.getAddressLine(i));  
                         }  
                           
                           
                 } catch (Exception e) {  
                         Log.e("DepartureList", "geocoder failed", e);  
                 }  
                   
                 return sb.toString();  
         }  
169                    
170                    
171          class LocatorTask extends AsyncTask<Void,Void,Void> {          class LocatorTask extends AsyncTask<Void,Void,Void> {

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

  ViewVC Help
Powered by ViewVC 1.1.20