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

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

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

revision 294 by torben, Tue Sep 1 20:28:55 2009 UTC revision 316 by torben, Fri Sep 11 08:48:18 2009 UTC
# Line 44  public class TrainInfoList extends ListA Line 44  public class TrainInfoList extends ListA
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);
# 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);
165                  intent.putExtra("code", station.getCode());                  intent.putExtra("stationid", station.getId());
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.294  
changed lines
  Added in v.316

  ViewVC Help
Powered by ViewVC 1.1.20