diff --git a/library/src/main/java/com/github/tbouron/shakedetector/library/ShakeDetector.java b/library/src/main/java/com/github/tbouron/shakedetector/library/ShakeDetector.java index bce10cfd9d37b4773d12f6b87a93b089a9433836..a8aaa60f6b09ff637031aeaa297f80a32fe470d3 100644 --- a/library/src/main/java/com/github/tbouron/shakedetector/library/ShakeDetector.java +++ b/library/src/main/java/com/github/tbouron/shakedetector/library/ShakeDetector.java @@ -47,6 +47,7 @@ public class ShakeDetector implements ICategoryOrientationDataCallback { private ArrayList mSensorBundles; private Object mLock; private int direction = 1; + long interval = 500l; /** * 上一次检测的时间 */ @@ -165,7 +166,7 @@ public class ShakeDetector implements ICategoryOrientationDataCallback { if (mSensorBundles.size() == 0) { mSensorBundles.add(sensorBundle); } else if (sensorBundle.getTimestamp() - mSensorBundles.get(mSensorBundles.size() - 1) - .getTimestamp() > INTERVAL) { + .getTimestamp() > interval) { mSensorBundles.add(sensorBundle); } } @@ -176,7 +177,7 @@ public class ShakeDetector implements ICategoryOrientationDataCallback { synchronized (mLock) { long currentTime = System.currentTimeMillis(); long diffTime = currentTime - mLastUpdateTime; - if (diffTime < INTERVAL) { + if (diffTime < interval) { return; } mLastUpdateTime = currentTime; @@ -205,7 +206,6 @@ public class ShakeDetector implements ICategoryOrientationDataCallback { } } - // 使用变化的精度 @Override public void onAccuracyDataModified(CategoryOrientation categoryOrientation, int i) { }