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


Java OrientationEventListener.ORIENTATION_UNKNOWN属性代码示例

本文整理汇总了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));
            }
        }
    };
}
 
开发者ID:shelDev,项目名称:droidCam,代码行数:20,代码来源:DisplayOrientationDetector.java

示例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);
	}
 
开发者ID:hubert1002,项目名称:WiCamera3D,代码行数:18,代码来源:Util.java

示例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);
	}
}
 
开发者ID:hubert1002,项目名称:WiCamera3D,代码行数:24,代码来源:VideoSurfaceView2D.java

示例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);
}
 
开发者ID:diedricm,项目名称:MapEver,代码行数:19,代码来源:CornerDetectionView.java

示例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);

}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:16,代码来源:VideoModule.java

示例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();
        }
    }
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:29,代码来源:VideoRecordingHints.java

示例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();
    }
}
 
开发者ID:asm-products,项目名称:nexus-camera,代码行数:18,代码来源:VideoModule.java

示例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();
		}
	}
}
 
开发者ID:pov1912,项目名称:Selfie-Camera,代码行数:25,代码来源:MainActivity.java

示例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!
}
 
开发者ID:actorapp,项目名称:droidkit-webrtc,代码行数:23,代码来源:VideoCaptureAndroid.java

示例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;
}
 
开发者ID:mcxiaoke,项目名称:fanfouapp-opensource,代码行数:24,代码来源:ImageHelper.java

示例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);
		}
	}
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:30,代码来源:LinphoneActivity.java

示例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;
}
 
开发者ID:chengzichen,项目名称:KrGallery,代码行数:14,代码来源:CameraSession.java

示例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;
}
 
开发者ID:uestccokey,项目名称:EZFilter,代码行数:14,代码来源:CameraFilterActivity.java

示例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);
}
 
开发者ID:staticbloc,项目名称:media,代码行数:32,代码来源:SimpleCameraImpl.java

示例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);
  }
}
 
开发者ID:staticbloc,项目名称:media,代码行数:35,代码来源:SimpleCameraImpl.java


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