Skip to content

Commit

Permalink
Use the current sensor machinery rather than the deprecated API.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpobst committed Feb 14, 2012
1 parent ac02807 commit 0024cf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion MapsDemo/MapViewCompassDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ protected override void OnResume ()
{
base.OnResume ();

sensor_manager.RegisterListener (rotate_view, SensorType.Orientation, SensorDelay.Ui);
var orientSensor = sensor_manager.GetDefaultSensor (SensorType.Orientation);
sensor_manager.RegisterListener (rotate_view, orientSensor, SensorDelay.Ui);

location_overlay.EnableMyLocation ();
}
Expand Down
8 changes: 5 additions & 3 deletions MapsDemo/RotateView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace MonoDroid.Samples.MapsDemo
{
class RotateView : ViewGroup, ISensorListener
class RotateView : ViewGroup, ISensorEventListener
{
const float SQ2 = 1.414213562373095f;
const float ROTATE_TOLERANCE = 2.0f;
Expand All @@ -36,9 +36,11 @@ public RotateView (Context context)
}

// When the sensor tells us we have moved, update
public void OnSensorChanged (int sensor, float[] values)
public void OnSensorChanged (SensorEvent e)
{
lock (lock_obj) {
var values = e.Values;

if (Math.Abs (heading - values[0]) > ROTATE_TOLERANCE) {
heading = values[0];
Invalidate ();
Expand Down Expand Up @@ -100,7 +102,7 @@ public override bool DispatchTouchEvent (MotionEvent ev)
return base.DispatchTouchEvent (ev);
}

public void OnAccuracyChanged (int sensor, int accuracy)
public void OnAccuracyChanged (Sensor sensor, int accuracy)
{
// TODO Auto-generated method stub
}
Expand Down

0 comments on commit 0024cf4

Please sign in to comment.