本文整理汇总了Java中android.view.OrientationEventListener.enable方法的典型用法代码示例。如果您正苦于以下问题:Java OrientationEventListener.enable方法的具体用法?Java OrientationEventListener.enable怎么用?Java OrientationEventListener.enable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.OrientationEventListener
的用法示例。
在下文中一共展示了OrientationEventListener.enable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RCTCameraView
import android.view.OrientationEventListener; //导入方法依赖的package包/类
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();
}
}
示例2: startOrientationChangeListener
import android.view.OrientationEventListener; //导入方法依赖的package包/类
/**
* 启动屏幕朝向改变监听函数 用于在屏幕横竖屏切换时改变保存的图片的方向
*/
private void startOrientationChangeListener() {
OrientationEventListener mOrEventListener = new OrientationEventListener(getContext()) {
@Override
public void onOrientationChanged(int rotation) {
if (((rotation >= 0) && (rotation <= 45)) || (rotation > 315)){
rotation=0;
}else if ((rotation > 45) && (rotation <= 135)) {
rotation=90;
}
else if ((rotation > 135) && (rotation <= 225)) {
rotation=180;
}
else if((rotation > 225) && (rotation <= 315)) {
rotation=270;
}else {
rotation=0;
}
if(rotation==mOrientation)
return;
mOrientation=rotation;
updateCameraOrientation();
}
};
mOrEventListener.enable();
}
示例3: OrientationPlugin
import android.view.OrientationEventListener; //导入方法依赖的package包/类
public OrientationPlugin(Context ctxt) {
this.ctxt=ctxt.getApplicationContext();
orientationEventListener=new OrientationEventListener(ctxt) {
@Override
public void onOrientationChanged(int orientation) {
lastOrientation=orientation;
}
};
if (orientationEventListener.canDetectOrientation()) {
orientationEventListener.enable();
}
else {
orientationEventListener.disable();
orientationEventListener=null;
}
}
示例4: FocusModePlugin
import android.view.OrientationEventListener; //导入方法依赖的package包/类
public FocusModePlugin(Context ctxt,
FocusMode focusMode,
boolean isVideo) {
this.ctxt=ctxt.getApplicationContext();
this.focusMode=focusMode;
this.isVideo=isVideo;
orientationEventListener=new OrientationEventListener(ctxt) {
@Override
public void onOrientationChanged(int orientation) {
lastOrientation=orientation;
}
};
if (orientationEventListener.canDetectOrientation()) {
orientationEventListener.enable();
}
else {
orientationEventListener.disable();
orientationEventListener=null;
}
}
示例5: OrientationPlugin
import android.view.OrientationEventListener; //导入方法依赖的package包/类
public OrientationPlugin(Context ctxt) {
this.ctxt=ctxt.getApplicationContext();
orientationEventListener=new OrientationEventListener(ctxt) {
@Override
public void onOrientationChanged(int orientation) {
if (lastOrientation!=orientation) {
AbstractCameraActivity.BUS
.post(new CameraEngine.OrientationChangedEvent());
}
lastOrientation=orientation;
}
};
if (orientationEventListener.canDetectOrientation()) {
orientationEventListener.enable();
}
else {
orientationEventListener.disable();
orientationEventListener=null;
}
}
示例6: enableCameraView
import android.view.OrientationEventListener; //导入方法依赖的package包/类
@Override
public void enableCameraView() {
// Start listening for orientation events
mCameraOrientationEventListener = new OrientationEventListener(this) {
@Override
public void onOrientationChanged(int orientation) {
if (mAppStateListeners != null) {
for (GeckoAppShell.AppStateListener listener: mAppStateListeners) {
listener.onOrientationChanged();
}
}
}
};
mCameraOrientationEventListener.enable();
// Try to make it fully transparent.
if (mCameraView instanceof SurfaceView) {
if (Versions.feature11Plus) {
mCameraView.setAlpha(0.0f);
}
ViewGroup mCameraLayout = (ViewGroup) findViewById(R.id.camera_layout);
// Some phones (eg. nexus S) need at least a 8x16 preview size
mCameraLayout.addView(mCameraView,
new AbsoluteLayout.LayoutParams(8, 16, 0, 0));
}
}
示例7: CameraSession
import android.view.OrientationEventListener; //导入方法依赖的package包/类
public CameraSession(CameraInfo info, Size preview, Size picture, int format) {
previewSize = preview;
pictureSize = picture;
pictureFormat = format;
cameraInfo = info;
SharedPreferences sharedPreferences = Gallery.applicationContext.getSharedPreferences("camera", Activity.MODE_PRIVATE);
currentFlashMode = sharedPreferences.getString(cameraInfo.frontCamera != 0 ? "flashMode_front" : "flashMode", Camera.Parameters.FLASH_MODE_OFF);
orientationEventListener = new OrientationEventListener(Gallery.applicationContext) {
@Override
public void onOrientationChanged(int orientation) {
if (orientationEventListener == null || !initied || orientation == ORIENTATION_UNKNOWN) {
return;
}
jpegOrientation = roundOrientation(orientation, jpegOrientation);
WindowManager mgr = (WindowManager)Gallery.applicationContext.getSystemService(Context.WINDOW_SERVICE);
int rotation = mgr.getDefaultDisplay().getRotation();
if (lastOrientation != jpegOrientation || rotation != lastDisplayOrientation) {
if (!isVideo) {
configurePhotoCamera();
}
lastDisplayOrientation = rotation;
lastOrientation = jpegOrientation;
}
}
};
if (orientationEventListener.canDetectOrientation()) {
orientationEventListener.enable();
} else {
orientationEventListener.disable();
orientationEventListener = null;
}
}
示例8: CameraSession
import android.view.OrientationEventListener; //导入方法依赖的package包/类
public CameraSession(CameraInfo info, Size preview, Size picture, int format) {
previewSize = preview;
pictureSize = picture;
pictureFormat = format;
cameraInfo = info;
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("camera", Activity.MODE_PRIVATE);
currentFlashMode = sharedPreferences.getString(cameraInfo.frontCamera != 0 ? "flashMode_front" : "flashMode", Camera.Parameters.FLASH_MODE_OFF);
orientationEventListener = new OrientationEventListener(ApplicationLoader.applicationContext) {
@Override
public void onOrientationChanged(int orientation) {
if (orientationEventListener == null || !initied) {
return;
}
WindowManager mgr = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
int rotation = mgr.getDefaultDisplay().getRotation();
if (lastOrientation != rotation) {
if (!isVideo) {
configurePhotoCamera();
}
lastOrientation = rotation;
}
}
};
if (orientationEventListener.canDetectOrientation()) {
orientationEventListener.enable();
} else {
orientationEventListener.disable();
orientationEventListener = null;
}
}
示例9: addOrientationListener
import android.view.OrientationEventListener; //导入方法依赖的package包/类
private void addOrientationListener() {
listener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) {
public void onOrientationChanged(int orientation) {
if ((orientation >= 230 && orientation <= 290) || (orientation >= 70 && orientation <= 90)) {
portrait.setText("True");
}
}
};
if (listener.canDetectOrientation()) listener.enable();
}
示例10: ReactOrientationListenerModule
import android.view.OrientationEventListener; //导入方法依赖的package包/类
public ReactOrientationListenerModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
final ReactApplicationContext thisContext = reactContext;
mOrientationListener = new OrientationEventListener(reactContext,
SensorManager.SENSOR_DELAY_NORMAL) {
@Override
public void onOrientationChanged(int orientation) {
WritableNativeMap params = new WritableNativeMap();
String orientationValue = "";
if(orientation == 0) {
orientationValue = "PORTRAIT";
} else {
orientationValue = "LANDSCAPE";
}
params.putString("orientation", orientationValue);
params.putString("device", getDeviceName());
if (thisContext.hasActiveCatalystInstance()) {
thisContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit("orientationDidChange", params);
}
}
};
if (mOrientationListener.canDetectOrientation() == true) {
mOrientationListener.enable();
} else {
mOrientationListener.disable();
}
}
开发者ID:walmartlabs,项目名称:react-native-orientation-listener,代码行数:33,代码来源:ReactOrientationListenerModule.java
示例11: ReactOrientationControllerModule
import android.view.OrientationEventListener; //导入方法依赖的package包/类
public ReactOrientationControllerModule(final ReactApplicationContext reactContext, Activity activity) {
super(reactContext);
this.reactContext = reactContext;
this.mActivity = activity;
mApplicationOrientationListener = new OrientationEventListener(reactContext) {
@Override
public void onOrientationChanged(int orientation) {
deviceOrientation = orientation;
if(lastDeviceOrientation.compareTo(getDeviceOrientationAsString())!=0){
lastDeviceOrientation = getDeviceOrientationAsString();
WritableNativeMap data = getDataMap();
try{
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit("orientationDidChange", data);
} catch (RuntimeException e) {
Log.e("ERROR ", "java.lang.RuntimeException: Trying to invoke JS before CatalystInstance has been set!");
}
}
}
};
if (mApplicationOrientationListener.canDetectOrientation() == true) {
mApplicationOrientationListener.enable();
} else {
mApplicationOrientationListener.disable();
}
}
开发者ID:inProgress-team,项目名称:react-native-orientation-controller,代码行数:32,代码来源:ReactOrientationControllerModule.java
示例12: init
import android.view.OrientationEventListener; //导入方法依赖的package包/类
public void init() {
if (!m_initialized) {
m_surfaceHolder = getHolder();
m_surfaceHolder.addCallback(this);
m_initialized = true;
final WindowManager windowManager = (WindowManager) m_activity.getSystemService(Context.WINDOW_SERVICE);
m_lastRotation = -1;
// Half rotations will change the layout from portrait to landscape and vice-versa. However,
// this won't account for 180 degree rotations since they remain in the same configuration. We
// need to listen for 180 orientation changes and update our camera orientation accordingly as well.
OrientationEventListener orientationEventListener = new OrientationEventListener(m_activity, SensorManager.SENSOR_DELAY_NORMAL) {
@Override
public void onOrientationChanged(int orientation) {
Display display = windowManager.getDefaultDisplay();
int rotation = display.getRotation();
if ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && rotation != m_lastRotation) {
try {
updateOrientation();
} catch (Exception e) {}
m_lastRotation = rotation;
}
}
};
if (orientationEventListener.canDetectOrientation()) {
orientationEventListener.enable();
}
}
}
示例13: addOrientationChangedListener
import android.view.OrientationEventListener; //导入方法依赖的package包/类
private void addOrientationChangedListener() {
mOrientationHasChanged = false;
mOrientationEventListener =
new OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL) {
@Override
public void onOrientationChanged(int orientation) {
mOrientationHasChanged = true;
}
};
mOrientationEventListener.enable();
}
示例14: CameraSession
import android.view.OrientationEventListener; //导入方法依赖的package包/类
public CameraSession(CameraInfo info, Size preview, Size picture, int format) {
previewSize = preview;
pictureSize = picture;
pictureFormat = format;
cameraInfo = info;
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("camera", Activity.MODE_PRIVATE);
currentFlashMode = sharedPreferences.getString(cameraInfo.frontCamera != 0 ? "flashMode_front" : "flashMode", Camera.Parameters.FLASH_MODE_OFF);
orientationEventListener = new OrientationEventListener(ApplicationLoader.applicationContext) {
@Override
public void onOrientationChanged(int orientation) {
if (orientationEventListener == null || !initied || orientation == ORIENTATION_UNKNOWN) {
return;
}
jpegOrientation = roundOrientation(orientation, jpegOrientation);
WindowManager mgr = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
int rotation = mgr.getDefaultDisplay().getRotation();
if (lastOrientation != jpegOrientation || rotation != lastDisplayOrientation) {
if (!isVideo) {
configurePhotoCamera();
}
lastDisplayOrientation = rotation;
lastOrientation = jpegOrientation;
}
}
};
if (orientationEventListener.canDetectOrientation()) {
orientationEventListener.enable();
} else {
orientationEventListener.disable();
orientationEventListener = null;
}
}
示例15: start
import android.view.OrientationEventListener; //导入方法依赖的package包/类
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);
}