本文整理汇总了Java中android.view.OrientationEventListener.ORIENTATION_UNKNOWN属性的典型用法代码示例。如果您正苦于以下问题:Java OrientationEventListener.ORIENTATION_UNKNOWN属性的具体用法?Java OrientationEventListener.ORIENTATION_UNKNOWN怎么用?Java OrientationEventListener.ORIENTATION_UNKNOWN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.OrientationEventListener
的用法示例。
在下文中一共展示了OrientationEventListener.ORIENTATION_UNKNOWN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DisplayOrientationDetector
public DisplayOrientationDetector(Context context) {
mOrientationEventListener = new OrientationEventListener(context) {
/** This is either Surface.Rotation_0, _90, _180, _270, or -1 (invalid). */
private int mLastKnownRotation = -1;
@Override
public void onOrientationChanged(int orientation) {
if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN ||
mDisplay == null) {
return;
}
final int rotation = mDisplay.getRotation();
if (mLastKnownRotation != rotation) {
mLastKnownRotation = rotation;
dispatchOnDisplayOrientationChanged(DISPLAY_ORIENTATIONS.get(rotation));
}
}
};
}
示例2: setRotationParameter
public static void setRotationParameter(Parameters parameters,
int cameraId, int orientation) {
// See android.hardware.Camera.Parameters.setRotation for
// documentation.
int rotation = 0;
if (orientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
CameraInfo info =
CameraHolder.instance().getCameraInfo()[cameraId];
// CameraInfo info = new CameraInfo();
// Camera.getCameraInfo(cameraId, info);
if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
rotation = (info.orientation - orientation + 360) % 360;
} else { // back-facing camera
rotation = (info.orientation + orientation) % 360;
}
}
parameters.setRotation(rotation);
}
示例3: setOrientationHint
@Override
public void setOrientationHint() {
// Util.setRotationParameter(camera_parameters, m_cameraIndex,
// WiCameraActivity.mOrientation);
// // System.out.println("拍照时的mOrientation="
// // + WiCameraActivity.mOrientation + "m_cameraIndex="
// // + m_cameraIndex);
// cameras.setParameters(camera_parameters);
if (cameras != null) {
int rotation = 0;
if (WiCameraActivity.mOrientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
CameraInfo info = CameraHolder.instance().getCameraInfo()[m_cameraIndex];
if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
rotation = (info.orientation
- WiCameraActivity.mOrientation + 360) % 360;
} else { // back-facing camera
rotation = (info.orientation + WiCameraActivity.mOrientation) % 360;
}
}
m_recorder.setOrientationHint(rotation);
}
}
示例4: updateOrientation
private void updateOrientation()
{
if(mCamera == null || device_orientation == OrientationEventListener.ORIENTATION_UNKNOWN)
return;
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(getCameraId(),info);
int rotation = 0;
if(info.facing == CameraInfo.CAMERA_FACING_FRONT)
{
rotation = (info.orientation - device_orientation +360) % 360;
}
else
{
rotation = (info.orientation + device_orientation) % 360;
}
Parameters params = mCamera.getParameters();
params.setRotation(rotation);
mCamera.setParameters(params);
}
示例5: onOrientationChanged
@Override
public void onOrientationChanged(int orientation) {
// We keep the last known orientation. So if the user first orient
// the camera then point the camera to floor or sky, we still have
// the correct orientation.
if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) {
return;
}
int newOrientation = CameraUtil.roundOrientation(orientation, mOrientation);
if (mOrientation != newOrientation) {
mOrientation = newOrientation;
}
mUI.onOrientationChanged(orientation);
}
示例6: onOrientationChanged
/**
* Handles orientation change by starting/stopping the video hint based on the
* new orientation.
*/
public void onOrientationChanged(int orientation) {
if (mLastOrientation == orientation) {
return;
}
mLastOrientation = orientation;
if (mLastOrientation == OrientationEventListener.ORIENTATION_UNKNOWN) {
return;
}
mIsInLandscape = isInLandscape();
if (getVisibility() == VISIBLE) {
if (mIsInLandscape) {
// Landscape.
mRotationAnimation.cancel();
// Start fading out.
if (mAlphaAnimator.isRunning()) {
return;
}
mAlphaAnimator.start();
} else {
// Portrait.
continueRotationAnimation();
}
}
}
示例7: onOrientationChanged
@Override
public void onOrientationChanged(int orientation) {
// We keep the last known orientation. So if the user first orient
// the camera then point the camera to floor or sky, we still have
// the correct orientation.
if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) return;
int newOrientation = CameraUtil.roundOrientation(orientation, mOrientation);
if (mOrientation != newOrientation) {
mOrientation = newOrientation;
}
// Show the toast after getting the first orientation changed.
if (mHandler.hasMessages(SHOW_TAP_TO_SNAPSHOT_TOAST)) {
mHandler.removeMessages(SHOW_TAP_TO_SNAPSHOT_TOAST);
showTapToSnapshotToast();
}
}
示例8: onOrientationChanged
private void onOrientationChanged(int orientation) {
/*
* if( MyDebug.LOG ) { Log.d(TAG, "onOrientationChanged()"); Log.d(TAG,
* "orientation: " + orientation); Log.d(TAG, "current_orientation: " +
* current_orientation); }
*/
if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN)
return;
int diff = Math.abs(orientation - current_orientation);
if (diff > 180)
diff = 360 - diff;
// only change orientation when sufficiently changed
if (diff > 60) {
orientation = (orientation + 45) / 90 * 90;
orientation = orientation % 360;
if (orientation != current_orientation) {
this.current_orientation = orientation;
if (MyDebug.LOG) {
Log.d(TAG, "current_orientation is now: "
+ current_orientation);
}
layoutUI();
}
}
}
示例9: VideoCaptureAndroid
public VideoCaptureAndroid(int id, long native_capturer) {
this.id = id;
this.native_capturer = native_capturer;
this.info = new Camera.CameraInfo();
Camera.getCameraInfo(id, info);
// Must be the last thing in the ctor since we pass a reference to |this|!
final VideoCaptureAndroid self = this;
orientationListener = new OrientationEventListener(GetContext()) {
@Override public void onOrientationChanged(int degrees) {
if (degrees == OrientationEventListener.ORIENTATION_UNKNOWN) {
return;
}
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
degrees = (info.orientation - degrees + 360) % 360;
} else { // back-facing
degrees = (info.orientation + degrees) % 360;
}
self.OnOrientationChanged(self.native_capturer, degrees);
}
};
// Don't add any code here; see the comment above |self| above!
}
示例10: roundOrientation
public static int roundOrientation(final int orientationInput) {
// landscape mode
int orientation = orientationInput;
if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) {
orientation = 0;
}
orientation = orientation % 360;
int retVal;
if (orientation < ((0 * 90) + 45)) {
retVal = 0;
} else if (orientation < ((1 * 90) + 45)) {
retVal = 90;
} else if (orientation < ((2 * 90) + 45)) {
retVal = 180;
} else if (orientation < ((3 * 90) + 45)) {
retVal = 270;
} else {
retVal = 0;
}
return retVal;
}
示例11: onOrientationChanged
@Override
public void onOrientationChanged(final int o) {
if (o == OrientationEventListener.ORIENTATION_UNKNOWN) {
return;
}
int degrees = 270;
if (o < 45 || o > 315)
degrees = 0;
else if (o < 135)
degrees = 90;
else if (o < 225)
degrees = 180;
if (mAlwaysChangingPhoneAngle == degrees) {
return;
}
mAlwaysChangingPhoneAngle = degrees;
Log.d("Phone orientation changed to ", degrees);
int rotation = (360 - degrees) % 360;
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null) {
lc.setDeviceRotation(rotation);
LinphoneCall currentCall = lc.getCurrentCall();
if (currentCall != null && currentCall.cameraEnabled() && currentCall.getCurrentParamsCopy().getVideoEnabled()) {
lc.updateCall(currentCall, null);
}
}
}
示例12: roundOrientation
private int roundOrientation(int orientation, int orientationHistory) {
boolean changeOrientation;
if (orientationHistory == OrientationEventListener.ORIENTATION_UNKNOWN) {
changeOrientation = true;
} else {
int dist = Math.abs(orientation - orientationHistory);
dist = Math.min( dist, 360 - dist );
changeOrientation = ( dist >= 45 + ORIENTATION_HYSTERESIS );
}
if (changeOrientation) {
return ((orientation + 45) / 90 * 90) % 360;
}
return orientationHistory;
}
示例13: roundOrientation
private int roundOrientation(int orientation, int orientationHistory) {
boolean changeOrientation;
if (orientationHistory == OrientationEventListener.ORIENTATION_UNKNOWN) {
changeOrientation = true;
} else {
int dist = Math.abs(orientation - orientationHistory);
dist = Math.min(dist, 360 - dist);
changeOrientation = (dist >= 45 + ORIENTATION_HYSTERESIS);
}
if (changeOrientation) {
return ((orientation + 45) / 90 * 90) % 360;
}
return orientationHistory;
}
示例14: close
@Override
public void close() {
if(videoCaptureSession != null) {
stopVideoRecording(videoCaptureSession, videoCaptureSessionCancelledOnClose);
}
orientationEventListener.disable();
currentCameraRotation = OrientationEventListener.ORIENTATION_UNKNOWN;
if (camera != null) {
camera.release();
camera = null;
}
if(callbacks != null) {
callbacks.onCameraClosed();
}
if(cameraPreview != null) {
cameraPreview.release();
}
if(shutterSoundOverride != null) {
shutterSoundOverride.close();
}
previewEnabled.set(false);
state.set(CLOSE);
smoothZooming.set(false);
}
示例15: setCameraOrientation
private synchronized void setCameraOrientation(int orientation) {
if(orientation == OrientationEventListener.ORIENTATION_UNKNOWN) {
orientation = 0;
}
int degrees = 0;
if(orientation > 315 || orientation <= 45) {
degrees = 0;
}
else if(orientation > 45 && orientation <= 135) {
degrees = 90;
}
else if(orientation > 135 && orientation <= 225) {
degrees = 180;
}
else if(orientation > 225 && orientation <= 315) {
degrees = 270;
}
if(currentCameraRotation == degrees) {
return;
}
currentCameraRotation = degrees;
int result = getCameraOrientation();
try {
Camera.Parameters parameters = camera.getParameters();
parameters.setRotation(result);
camera.setParameters(parameters);
}
catch(Exception e) {
Log.w("SimpleCamera", "Exception while setting camera orientation", e);
}
}