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


Java OrientationEventListener.canDetectOrientation方法代码示例

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


在下文中一共展示了OrientationEventListener.canDetectOrientation方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
    }
}
 
开发者ID:jonathan68,项目名称:react-native-camera,代码行数:21,代码来源:RCTCameraView.java

示例2: 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

示例3: 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

示例4: 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

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

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

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

示例8: 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

示例9: 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

示例10: 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();
        }
    }
}
 
开发者ID:rapidpro,项目名称:surveyor,代码行数:33,代码来源:CameraPreview.java

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

示例12: 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);
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:66,代码来源:CameraHeadService.java


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