RNSimpleCompassModule.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:react-native-simple-compass 作者:
@Override
public void onSensorChanged(SensorEvent event) {
    if( event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR ){
        // calculate th rotation matrix
        SensorManager.getRotationMatrixFromVector(rMat, event.values);
        // get the azimuth value (orientation[0]) in degree
        int newAzimuth = (int) ( Math.toDegrees( SensorManager.getOrientation( rMat, orientation )[0] ) + 360 ) % 360;

        //dont react to changes smaller than the filter value
        if (Math.abs(mAzimuth - newAzimuth) < mFilter) {
            return;
        }

        mAzimuth = newAzimuth;

        getReactApplicationContext()
                .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
                .emit("HeadingUpdated", mAzimuth);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号