Search in sources :

Example 1 with ICameraSettingModel

use of com.yydcdut.note.model.camera.ICameraSettingModel in project PhotoNoter by yydcdut.

the class CameraPresenterImpl method attachView.

@Override
public void attachView(@NonNull IView iView) {
    mICameraView = (ICameraView) iView;
    mCurrentCameraId = mLocalStorageUtils.getCameraSaveCameraId();
    mPictureSize = getPictureSize();
    mCameraModel.openCamera(mCurrentCameraId, new ICameraModel.OnCameraOpenedCallback() {

        @Override
        public void onOpen(IPreviewModel previewModel, ICameraSettingModel cameraSettingModel) {
            mPreviewModel = previewModel;
            mCameraSettingModel = cameraSettingModel;
            if (mPictureSize == null) {
                mPictureSize = savePictureSizes(mCurrentCameraId);
            }
            initUIState();
            initLogicState();
            mPreviewSize = getSuitablePreviewSize(mCameraSettingModel.getSupportPreviewSizes());
            if (mRatioState == Const.LAYOUT_PERSONAL_RATIO_FULL) {
                mICameraView.doFullRatioAnimation();
            } else if (mRatioState == Const.LAYOUT_PERSONAL_RATIO_4_3) {
                mICameraView.do43RatioAnimation();
            } else {
                mICameraView.do11RatioAnimation();
            }
            mICameraView.setSize(mPreviewSize.getHeight(), mPreviewSize.getWidth());
            onGridClick(-1);
        }

        @Override
        public void onError() {
        }
    }, getCameraRotation(), mPictureSize);
    initLocation();
    mHandler = new Handler(this);
}
Also used : ICameraModel(com.yydcdut.note.model.camera.ICameraModel) IPreviewModel(com.yydcdut.note.model.camera.IPreviewModel) ICameraSettingModel(com.yydcdut.note.model.camera.ICameraSettingModel) Handler(android.os.Handler)

Example 2 with ICameraSettingModel

use of com.yydcdut.note.model.camera.ICameraSettingModel in project PhotoNoter by yydcdut.

the class CameraPresenterImpl method onCameraIdClick.

@Override
public void onCameraIdClick(int state) {
    if (mCameraSettingModel != null && mCameraSettingModel.getNumberOfCameras() == 2) {
        if (Const.CAMERA_BACK.equals(mCurrentCameraId)) {
            mCurrentCameraId = Const.CAMERA_FRONT;
        } else {
            mCurrentCameraId = Const.CAMERA_BACK;
        }
        closeCamera();
        final Size pictureSize = getPictureSize();
        mCameraModel.openCamera(mCurrentCameraId, new ICameraModel.OnCameraOpenedCallback() {

            @Override
            public void onOpen(IPreviewModel previewModel, ICameraSettingModel cameraSettingModel) {
                mPreviewModel = previewModel;
                mCameraSettingModel = cameraSettingModel;
                if (pictureSize == null) {
                    savePictureSizes(mCurrentCameraId);
                }
                initUIState();
                initLogicState();
                mPreviewSize = getSuitablePreviewSize(mCameraSettingModel.getSupportPreviewSizes());
                mPreviewModel.startPreview(mPreviewSurface, new IPreviewModel.OnCameraPreviewCallback() {

                    @Override
                    public void onPreview(ICaptureModel captureModel, ICameraFocus cameraFocus) {
                        mCaptureModel = captureModel;
                        mCameraFocus = cameraFocus;
                    }

                    @Override
                    public void onPreviewError() {
                    }
                }, mPreviewSize);
            }

            @Override
            public void onError() {
            }
        }, getCameraRotation(), pictureSize);
    }
}
Also used : ICameraFocus(com.yydcdut.note.model.camera.ICameraFocus) ICameraModel(com.yydcdut.note.model.camera.ICameraModel) IPreviewModel(com.yydcdut.note.model.camera.IPreviewModel) Size(com.yydcdut.note.utils.camera.param.Size) ICameraSettingModel(com.yydcdut.note.model.camera.ICameraSettingModel) ICaptureModel(com.yydcdut.note.model.camera.ICaptureModel)

Aggregations

ICameraModel (com.yydcdut.note.model.camera.ICameraModel)2 ICameraSettingModel (com.yydcdut.note.model.camera.ICameraSettingModel)2 IPreviewModel (com.yydcdut.note.model.camera.IPreviewModel)2 Handler (android.os.Handler)1 ICameraFocus (com.yydcdut.note.model.camera.ICameraFocus)1 ICaptureModel (com.yydcdut.note.model.camera.ICaptureModel)1 Size (com.yydcdut.note.utils.camera.param.Size)1