/[projects]/android/MockLocation/src/dk/thoerup/mocklocation/MockLocationView.java
ViewVC logotype

Diff of /android/MockLocation/src/dk/thoerup/mocklocation/MockLocationView.java

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

revision 359 by torben, Tue Sep 29 19:40:07 2009 UTC revision 360 by torben, Tue Sep 29 19:50:32 2009 UTC
# Line 19  import android.widget.ListView; Line 19  import android.widget.ListView;
19  public class MockLocationView extends ListActivity {  public class MockLocationView extends ListActivity {
20      /** Called when the activity is first created. */      /** Called when the activity is first created. */
21                    
22            private static final String PROVIDERNAME = "gps";
23                    
24          LocationManager locationManager;          LocationManager locationManager;
25                    
# Line 65  public class MockLocationView extends Li Line 66  public class MockLocationView extends Li
66      @Override      @Override
67          protected void onResume() {          protected void onResume() {
68                  super.onResume();                  super.onResume();
69          LocationProvider gps2 = locationManager.getProvider("gps2");          LocationProvider provider = locationManager.getProvider(PROVIDERNAME);
70          isEnabled = (gps2 != null);          isEnabled = (provider != null);
71          enableButtons();          enableButtons();
72          Log.e("onResume", "onResume");          Log.e("onResume", "onResume");
73          }          }
# Line 94  public class MockLocationView extends Li Line 95  public class MockLocationView extends Li
95            
96      View.OnClickListener enableListener = new View.OnClickListener() {      View.OnClickListener enableListener = new View.OnClickListener() {
97                  public void onClick(View v) {                  public void onClick(View v) {
98                          locationManager.addTestProvider("gps2", false, true, true, false, false, false, false, 0, Criteria.ACCURACY_FINE );                          locationManager.addTestProvider(PROVIDERNAME, false, true, true, false, false, false, false, 0, Criteria.ACCURACY_FINE );
99                          locationManager.setTestProviderEnabled("gps2", true);                          locationManager.setTestProviderEnabled(PROVIDERNAME, true);
100                                                    
101                                                    
102                          isEnabled = true;                          isEnabled = true;
# Line 105  public class MockLocationView extends Li Line 106  public class MockLocationView extends Li
106            
107      View.OnClickListener disableListener = new View.OnClickListener() {      View.OnClickListener disableListener = new View.OnClickListener() {
108                  public void onClick(View v) {                  public void onClick(View v) {
109                          locationManager.removeTestProvider("gps2");                          locationManager.removeTestProvider(PROVIDERNAME);
110                                                    
111                          isEnabled = false;                          isEnabled = false;
112                          enableButtons();                          enableButtons();
# Line 120  public class MockLocationView extends Li Line 121  public class MockLocationView extends Li
121                                                    
122                                  LocationBean bean = locations.get(selected);                                  LocationBean bean = locations.get(selected);
123                                                                    
124                                  Location loc = new Location("gps2");                                  Location loc = new Location(PROVIDERNAME);
125                                  loc.setLatitude( bean.getLatitude() );                                  loc.setLatitude( bean.getLatitude() );
126                                  loc.setLongitude( bean.getLongitude() );                                  loc.setLongitude( bean.getLongitude() );
127                                                    
128                                  locationManager.setTestProviderLocation("gps2", loc);                                  locationManager.setTestProviderLocation(PROVIDERNAME, loc);
129                          } else {                          } else {
130                                  Log.e("mocklocation", "No item selected " + selected);                                  Log.e("mocklocation", "No item selected " + selected);
131                          }                          }

Legend:
Removed from v.359  
changed lines
  Added in v.360

  ViewVC Help
Powered by ViewVC 1.1.20