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


Java OrientationEventListener类代码示例

本文整理汇总了Java中android.view.OrientationEventListener的典型用法代码示例。如果您正苦于以下问题:Java OrientationEventListener类的具体用法?Java OrientationEventListener怎么用?Java OrientationEventListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: DisplayOrientationDetector

import android.view.OrientationEventListener; //导入依赖的package包/类
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,代码行数:21,代码来源:DisplayOrientationDetector.java

示例2: 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();
    }
}
 
开发者ID:jonathan68,项目名称:react-native-camera,代码行数:21,代码来源:RCTCameraView.java

示例3: onViewCreated

import android.view.OrientationEventListener; //导入依赖的package包/类
@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,代码行数:19,代码来源:Camera2RawFragment.java

示例4: 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();
}
 
开发者ID:Alex-Jerry,项目名称:LLApp,代码行数:30,代码来源:CameraView.java

示例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) {
      lastOrientation=orientation;
    }
  };

  if (orientationEventListener.canDetectOrientation()) {
    orientationEventListener.enable();
  }
  else {
    orientationEventListener.disable();
    orientationEventListener=null;
  }
}
 
开发者ID:code-mc,项目名称:FacerecognitionFlowpilots,代码行数:19,代码来源:OrientationPlugin.java

示例6: addToCaptureRequest

import android.view.OrientationEventListener; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void addToCaptureRequest(CameraCharacteristics cc,
                                boolean facingFront,
                                CaptureRequest.Builder captureBuilder) {
  // based on https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#JPEG_ORIENTATION

  int pictureOrientation=0;

  if (lastOrientation!=android.view.OrientationEventListener.ORIENTATION_UNKNOWN) {
    int sensorOrientation=cc.get(CameraCharacteristics.SENSOR_ORIENTATION);
    int deviceOrientation=(lastOrientation + 45) / 90 * 90;

    if (facingFront) {
      deviceOrientation = -deviceOrientation;
    }

    pictureOrientation=(sensorOrientation + deviceOrientation + 360) % 360;
  }

  captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, pictureOrientation);
}
 
开发者ID:code-mc,项目名称:FacerecognitionFlowpilots,代码行数:25,代码来源:OrientationPlugin.java

示例7: setRotationParameter

import android.view.OrientationEventListener; //导入依赖的package包/类
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,代码行数:19,代码来源:Util.java

示例8: setOrientationHint

import android.view.OrientationEventListener; //导入依赖的package包/类
@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,代码行数:25,代码来源:VideoSurfaceView2D.java

示例9: onOrientationChanged

import android.view.OrientationEventListener; //导入依赖的package包/类
@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,代码行数:17,代码来源:VideoModule.java

示例10: onOrientationChanged

import android.view.OrientationEventListener; //导入依赖的package包/类
/**
 * 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,代码行数:30,代码来源:VideoRecordingHints.java

示例11: 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;
  }
}
 
开发者ID:commonsguy,项目名称:cwac-cam2,代码行数:23,代码来源:FocusModePlugin.java

示例12: 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;
  }
}
 
开发者ID:commonsguy,项目名称:cwac-cam2,代码行数:24,代码来源:OrientationPlugin.java

示例13: addToCaptureRequest

import android.view.OrientationEventListener; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void addToCaptureRequest(CameraSession session,
                                CameraCharacteristics cc,
                                boolean facingFront,
                                CaptureRequest.Builder captureBuilder) {
  // based on https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#JPEG_ORIENTATION

  int pictureOrientation=0;

  if (lastOrientation!=android.view.OrientationEventListener.ORIENTATION_UNKNOWN) {
    int sensorOrientation=cc.get(CameraCharacteristics.SENSOR_ORIENTATION);
    int deviceOrientation=(lastOrientation + 45) / 90 * 90;

    if (facingFront) {
      deviceOrientation = -deviceOrientation;
    }

    pictureOrientation=(sensorOrientation + deviceOrientation + 360) % 360;
  }

  captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, pictureOrientation);
}
 
开发者ID:commonsguy,项目名称:cwac-cam2,代码行数:26,代码来源:OrientationPlugin.java

示例14: 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));
    }
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:27,代码来源:GeckoApp.java

示例15: onOrientationChanged

import android.view.OrientationEventListener; //导入依赖的package包/类
@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,代码行数:19,代码来源:VideoModule.java


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