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