當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。