当前位置: 首页>>代码示例>>Java>>正文


Java SensorManager.SENSOR_DELAY_NORMAL属性代码示例

本文整理汇总了Java中android.hardware.SensorManager.SENSOR_DELAY_NORMAL属性的典型用法代码示例。如果您正苦于以下问题:Java SensorManager.SENSOR_DELAY_NORMAL属性的具体用法?Java SensorManager.SENSOR_DELAY_NORMAL怎么用?Java SensorManager.SENSOR_DELAY_NORMAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.hardware.SensorManager的用法示例。


在下文中一共展示了SensorManager.SENSOR_DELAY_NORMAL属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RCTCameraView

public RCTCameraView(Context context) {
    super(context);
    this._context = context;
    RCTCamera.createInstance(getDeviceOrientation(context));

    _orientationListener = new OrientationEventListener(context, SensorManager.SENSOR_DELAY_NORMAL) {
        @Override
        public void onOrientationChanged(int orientation) {
            if (setActualDeviceOrientation(_context)) {
                layoutViewFinder();
            }
        }
    };

    if (_orientationListener.canDetectOrientation()) {
        _orientationListener.enable();
    } else {
        _orientationListener.disable();
    }
}
 
开发者ID:jonathan68,项目名称:react-native-camera,代码行数:20,代码来源:RCTCameraView.java

示例2: onViewCreated

@Override
public void onViewCreated(final View view, Bundle savedInstanceState) {
    view.findViewById(R.id.picture).setOnClickListener(this);
    mTextureView = (AutoFitTextureView) view.findViewById(R.id.texture);

    // Setup a new OrientationEventListener.  This is used to handle rotation events like a
    // 180 degree rotation that do not normally trigger a call to onCreate to do view re-layout
    // or otherwise cause the preview TextureView's size to change.
    mOrientationListener = new OrientationEventListener(getActivity(),
            SensorManager.SENSOR_DELAY_NORMAL) {
        @Override
        public void onOrientationChanged(int orientation) {
            if (mTextureView != null && mTextureView.isAvailable()) {
                configureTransform(mTextureView.getWidth(), mTextureView.getHeight());
            }
        }
    };
}
 
开发者ID:OkayCamera,项目名称:OkayCamera-Android,代码行数:18,代码来源:Camera2RawFragment.java

示例3: listen

public void listen(Context context, RotationCallback callback) {
    // Stop to make sure we're not registering the listening twice.
    stop();

    // Only use the ApplicationContext. In case of a memory leak (e.g. from a framework bug),
    // this will result in less being leaked.
    context = context.getApplicationContext();

    this.callback = callback;

    this.windowManager = (WindowManager) context
            .getSystemService(Context.WINDOW_SERVICE);

    this.orientationEventListener = new OrientationEventListener(context, SensorManager.SENSOR_DELAY_NORMAL) {
        @Override
        public void onOrientationChanged(int orientation) {
            WindowManager localWindowManager = windowManager;
            RotationCallback localCallback = RotationListener.this.callback;
            if(windowManager != null && localCallback != null) {
                int newRotation = localWindowManager.getDefaultDisplay().getRotation();
                if (newRotation != lastRotation) {
                    lastRotation = newRotation;
                    localCallback.onRotationChanged(newRotation);
                }
            }
        }
    };
    this.orientationEventListener.enable();

    lastRotation = windowManager.getDefaultDisplay().getRotation();
}
 
开发者ID:yinhaojun,项目名称:ZxingForAndroid,代码行数:31,代码来源:RotationListener.java

示例4: sensorsSpeed

@ProtoMethod(description = "Set the speed of the sensor 'slow', 'fast', 'normal'", example = "")
@ProtoMethodParam(params = {"speed=['slow', 'fast', 'normal']"})
public void sensorsSpeed(String speed) {
    if (speed.equals("slow")) {
        this.speed = SensorManager.SENSOR_DELAY_UI;
    } else if (speed.equals("fast")) {
        this.speed = SensorManager.SENSOR_DELAY_FASTEST;
    } else {
        this.speed = SensorManager.SENSOR_DELAY_NORMAL;
    }
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:11,代码来源:CustomSensorManager.java

示例5: onViewCreated

@Override
public void onViewCreated(final View view, Bundle savedInstanceState) {
    view.findViewById(R.id.capture).setOnClickListener(this);
    view.findViewById(R.id.switch_camera).setOnClickListener(this);
    mTextureView = (AutoFitTextureView) view.findViewById(R.id.texture_view_camera2);
    mImageShow = (ImageView) view.findViewById(R.id.iv_show_camera2);
    mTimer = (ImageView) view.findViewById(R.id.timer);
    mTimeText = (TextView) view.findViewById(R.id.timer_text);
    mFlashBtn = (ImageView) view.findViewById(R.id.flash);
    mIvFocus = (ImageView) view.findViewById(R.id.iv_focus);
    mIvHdr = (ImageView) view.findViewById(R.id.hdr);
    mTimer.setOnClickListener(this);
    mFlashBtn.setOnClickListener(this);
    mIvHdr.setOnClickListener(this);

    mTextureView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            int actionMasked = MotionEventCompat.getActionMasked(event);
            int fingerX, fingerY;
            int length = (int) (getResources().getDisplayMetrics().density * 80);
            switch (actionMasked) {
                case MotionEvent.ACTION_DOWN:
                    fingerX = (int) event.getX();
                    fingerY = (int) event.getY();
                    LogUtil.d("onTouch: x->" + fingerX + ",y->" + fingerY);

                    mIvFocus.setX(fingerX - length / 2);
                    mIvFocus.setY(fingerY - length / 2);

                    mIvFocus.setVisibility(View.VISIBLE);
                    triggerFocusArea(fingerX, fingerY);

                    break;
            }

            return false;
        }
    });

    // Setup a new OrientationEventListener.  This is used to handle rotation events like a
    // 180 degree rotation that do not normally trigger a call to onCreate to do view re-layout
    // or otherwise cause the preview TextureView's size to change.
    mOrientationListener = new OrientationEventListener(getActivity(),
            SensorManager.SENSOR_DELAY_NORMAL) {
        @Override
        public void onOrientationChanged(int orientation) {
            if (mTextureView != null && mTextureView.isAvailable()) {
                configureTransform(mTextureView.getWidth(), mTextureView.getHeight());
            }
        }
    };
}
 
开发者ID:gengqifu,项目名称:361Camera,代码行数:53,代码来源:Camera2Fragment.java

示例6: start

private void start(final boolean isCamera) {
    Log.d("ImageTakin", "StartCommand()");
    pref = getApplicationContext().getSharedPreferences("MyPref", 0);
    editor = pref.edit();
    if (mCamera != null) {
        queue.removeCallbacks(null);
        mCamera.setPreviewCallback(null);
        mCamera.stopPreview();
        mCamera.release();
        mCamera = Camera.open();
    } else
        mCamera = getCameraInstance();
    parameters = mCamera.getParameters();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && parameters.getSupportedFocusModes().contains(
            Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
        parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
    } else if (parameters.getSupportedFocusModes().contains(
            Camera.Parameters.FOCUS_MODE_AUTO)) {
        parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
    }
    mCamera.setParameters(parameters);
    size = parameters.getPreviewSize();
    if (registeredShieldsIDs.contains(UIShield.COLOR_DETECTION_SHIELD.name()))
        mCamera.setPreviewCallback(previewCallback);
    windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

    params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.TYPE_PRIORITY_PHONE, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.RGBX_8888);
    params.gravity = Gravity.TOP | Gravity.LEFT;
    DisplayMetrics metrics = new DisplayMetrics();
    windowManager.getDefaultDisplay().getMetrics(metrics);
    int expectedHeight = metrics.heightPixels - ((int) (250 * metrics.density + .5f));
    int expectedWidth = ((expectedHeight * (size == null ? metrics.widthPixels : size.height)) / (size == null ? metrics.heightPixels : size.width));
    params.width = 1;// metrics.widthPixels - ((int) (60 * metrics.density + .5f));
    params.height = 1;
    params.x = (int) ((metrics.widthPixels / 2) - expectedWidth / 2);
    params.y = (int) (150 * metrics.density + .5f);
    params.alpha = 1;
    sv = new SurfaceView(getApplicationContext());
    windowManager.addView(sv, params);
    params = (WindowManager.LayoutParams) sv.getLayoutParams();
    sHolder = sv.getHolder();
    sHolder.addCallback(this);

    mOrientationEventListener = new OrientationEventListener(this,
            SensorManager.SENSOR_DELAY_NORMAL) {

        @Override
        public void onOrientationChanged(int orientation) {
            if (orientation == ORIENTATION_UNKNOWN) return;

            mOrientation = (orientation + 45) / 90 * 90;
        }
    };
    if (mOrientationEventListener.canDetectOrientation()) {
        mOrientationEventListener.enable();
    }
    // tells Android that this surface will have its data constantly
    // replaced
    if (Build.VERSION.SDK_INT < 11)
        sHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:65,代码来源:CameraHeadService.java

示例7: before

@Override
protected void before(XParam param) throws Throwable {
	switch (mMethod) {
	case getDefaultSensor:
		if (isRestricted(param))
			param.setResult(null);
		else if (param.args.length > 0 && param.args[0] instanceof Integer)
			if (isRestricted(param, (Integer) param.args[0]))
				param.setResult(null);
		break;

	case getSensorList:
		if (isRestricted(param))
			param.setResult(new ArrayList<Sensor>());
		else if (param.args.length > 0 && param.args[0] instanceof Integer)
			if (isRestricted(param, (Integer) param.args[0]))
				param.setResult(new ArrayList<Sensor>());
		break;

	case registerListener:
		if (param.args.length > 2 && param.args[1] instanceof Sensor && param.args[2] instanceof Integer) {
			int type = ((Sensor) param.args[1]).getType();
			if (type == Sensor.TYPE_GYROSCOPE || type == Sensor.TYPE_GYROSCOPE_UNCALIBRATED) {
				int rateUs = (Integer) param.args[2];

				// http://developer.android.com/guide/topics/sensors/sensors_overview.html
				if (rateUs == SensorManager.SENSOR_DELAY_NORMAL)
					return; // 200,000 us
				else if (rateUs == SensorManager.SENSOR_DELAY_UI)
					return; // 60,000 us
				else if (rateUs == SensorManager.SENSOR_DELAY_GAME)
					return; // 20,000 us
				else if (rateUs == SensorManager.SENSOR_DELAY_FASTEST)
					; // 0 us

				if (rateUs < cMaxRateUs) // 10,000 us
					if (isRestricted(param))
						param.args[2] = cMaxRateUs;
			}
		}
		break;
	}
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:43,代码来源:XSensorManager.java

示例8: GyroViewListener

/**
 * Creates a new GyroViewListener
 *
 * @param activity containing the views to orient. The Activity must
 *                 have a static orientation set in the manifest file (ie.
 *                 android:screenOrientation=portrait|landscape|reversePortrait|
 *                 reverseLandscape).
 *
 * @throws IllegalStateException
 */
public GyroViewListener(Activity activity) throws IllegalStateException {
    this(activity, SensorManager.SENSOR_DELAY_NORMAL);
}
 
开发者ID:brandenfung,项目名称:GyroView,代码行数:13,代码来源:GyroViewListener.java


注:本文中的android.hardware.SensorManager.SENSOR_DELAY_NORMAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。