endian11
2019-09-19 7c8083846306886aa7a408640e4faa108ca6ec28
拍照功能加入log;主界面退出系统点击后打开拍照界面;
3个文件已修改
40 ■■■■■ 已修改文件
app/src/main/AndroidManifest.xml 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/TakePhotoFragment.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/AndroidManifest.xml
app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java
@@ -84,19 +84,23 @@
                break;
            case R.id.exit_sys:
                //退出系统
                AlertDialog.Builder builder = new AlertDialog.Builder(_mActivity);
                builder.setMessage("您将退出系统,请确认数据已保存").setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        _mActivity.finish();
//                AlertDialog.Builder builder = new AlertDialog.Builder(_mActivity);
//                builder.setMessage("您将退出系统,请确认数据已保存").setPositiveButton("确定", new DialogInterface.OnClickListener() {
//                    @Override
//                    public void onClick(DialogInterface dialog, int which) {
//                        _mActivity.finish();
//                    }
//                }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
//                    @Override
//                    public void onClick(DialogInterface dialog, int which) {
//                        dialog.dismiss();
//                    }
//                }).show();
                    TakePhotoFragment takePhotoFragment = findFragment(TakePhotoFragment.class);
                    if (takePhotoFragment == null){
                        takePhotoFragment = TakePhotoFragment.newInstance();
                    }
                }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).show();
                    start(takePhotoFragment);
                break;
            case R.id.system_setting:
app/src/main/java/safeluck/drive/evaluation/fragment/TakePhotoFragment.java
@@ -58,6 +58,7 @@
import me.yokeyword.fragmentation.SupportFragment;
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.customview.AutoFitTextureView;
import safeluck.drive.evaluation.util.MyLog;
/**
 * MyApplication2
@@ -183,6 +184,7 @@
        @Override
        public void onOpened(@NonNull CameraDevice cameraDevice) {
            // This method is called when the camera is opened.  We start camera preview here.
            MyLog.i(TAG,"Camera Device onOpened");
            mCameraOpenCloseLock.release();
            mCameraDevice = cameraDevice;
            createCameraPreviewSession();
@@ -190,6 +192,7 @@
        @Override
        public void onDisconnected(@NonNull CameraDevice cameraDevice) {
            MyLog.i(TAG,"Camera Device onDisconnected");
            mCameraOpenCloseLock.release();
            cameraDevice.close();
            mCameraDevice = null;
@@ -197,6 +200,7 @@
        @Override
        public void onError(@NonNull CameraDevice cameraDevice, int error) {
            MyLog.i(TAG,"Camera Device onError");
            mCameraOpenCloseLock.release();
            cameraDevice.close();
            mCameraDevice = null;
@@ -517,6 +521,7 @@
                // Find out if we need to swap dimension to get the preview size relative to sensor
                // coordinate.
                int displayRotation = activity.getWindowManager().getDefaultDisplay().getRotation();
                MyLog.i(TAG,"displayRotation="+displayRotation);
                //noinspection ConstantConditions
                mSensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
                boolean swappedDimensions = false;
@@ -543,7 +548,7 @@
                int rotatedPreviewHeight = height;
                int maxPreviewWidth = displaySize.x;
                int maxPreviewHeight = displaySize.y;
                MyLog.i(TAG,"swappedDimensions="+swappedDimensions);
                if (swappedDimensions) {
                    rotatedPreviewWidth = height;
                    rotatedPreviewHeight = width;
@@ -565,9 +570,10 @@
                mPreviewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class),
                        rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth,
                        maxPreviewHeight, largest);
                MyLog.i(TAG,"chooseOptimalSize="+mPreviewSize.getWidth()+":"+mPreviewSize.getHeight());
                // We fit the aspect ratio of TextureView to the size of preview we picked.
                int orientation = getResources().getConfiguration().orientation;
                MyLog.i(TAG,"getResources().getConfiguration().orientation="+orientation);
                if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                    mTextureView.setAspectRatio(
                            mPreviewSize.getWidth(), mPreviewSize.getHeight());
@@ -581,6 +587,7 @@
                mFlashSupported = available == null ? false : available;
                mCameraId = cameraId;
                MyLog.i(TAG,"CameraID="+mCameraId+ " FlashSupported="+mFlashSupported);
                return;
            }
        } catch (CameraAccessException e) {
@@ -745,6 +752,7 @@
        RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth());
        float centerX = viewRect.centerX();
        float centerY = viewRect.centerY();
        MyLog.i(TAG,"configureTransform centerX="+centerX+" CenterY="+centerY+" getDefaultDisplay().getRotation()="+rotation);
        if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
            bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
            matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);