-
Notifications
You must be signed in to change notification settings - Fork 6
/
StepDetector.java
executable file
·53 lines (41 loc) · 1.24 KB
/
StepDetector.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package cz.muni.fi.sandbox.service.stepdetector;
import java.util.ArrayList;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.util.Log;
/**
* Step detector base class. Can be used as a dummy step detector. Doesn't
* detect any steps.
*
*/
public class StepDetector implements SensorEventListener, IStepDetector {
protected ArrayList<IStepListener> mStepListeners = new ArrayList<IStepListener>();
public void addStepListener(IStepListener sl) {
if (sl != null) {
mStepListeners.add(sl);
}
}
@Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
protected void notifyOnStep(StepEvent event) {
for (IStepListener stepListener : mStepListeners) {
stepListener.onStepEvent(event);
}
Log.d("TAG", event.toString());
}
public static StepDetector stepDetectorFactory(String detectorName) {
if (detectorName.equals("moving_average")) {
return new MovingAverageStepDetector();
} else if (detectorName.equals("null")) {
return new StepDetector();
}
return new StepDetector();
}
}