From a019f256bb772644567bba4e863aad8068ba9b7d Mon Sep 17 00:00:00 2001 From: aiWean <1581209979@qq.com> Date: Mon, 24 Aug 2020 10:31:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/api21/com/google/android/cameraview/Camera2.java | 3 ++- .../src/main/java/com/ailiwean/core/view/NBZxingView.kt | 3 ++- .../main/java/com/google/android/cameraview/CameraView.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/module_camera/src/main/api21/com/google/android/cameraview/Camera2.java b/module_camera/src/main/api21/com/google/android/cameraview/Camera2.java index d21632f..7bbbb9f 100644 --- a/module_camera/src/main/api21/com/google/android/cameraview/Camera2.java +++ b/module_camera/src/main/api21/com/google/android/cameraview/Camera2.java @@ -356,7 +356,8 @@ void takePicture() { @Override void setDisplayOrientation(int displayOrientation) { mDisplayOrientation = displayOrientation; - mPreview.setDisplayOrientation(mDisplayOrientation); + if (mPreview != null) + mPreview.setDisplayOrientation(mDisplayOrientation); } @Override diff --git a/module_camera/src/main/java/com/ailiwean/core/view/NBZxingView.kt b/module_camera/src/main/java/com/ailiwean/core/view/NBZxingView.kt index 8385ede..71ff60d 100644 --- a/module_camera/src/main/java/com/ailiwean/core/view/NBZxingView.kt +++ b/module_camera/src/main/java/com/ailiwean/core/view/NBZxingView.kt @@ -102,7 +102,8 @@ abstract class NBZxingView @JvmOverloads constructor(context: Context, attribute override fun onPause() { super.onPause() - scan_bar.stopAnim() + if (scan_bar != null) + scan_bar.stopAnim() } override fun onDestroy() { diff --git a/module_camera/src/main/java/com/google/android/cameraview/CameraView.java b/module_camera/src/main/java/com/google/android/cameraview/CameraView.java index fb65638..7af7915 100644 --- a/module_camera/src/main/java/com/google/android/cameraview/CameraView.java +++ b/module_camera/src/main/java/com/google/android/cameraview/CameraView.java @@ -129,7 +129,6 @@ public CameraView(Context context, AttributeSet attrs, int defStyleAttr) { } else { mImpl = new Camera2Api23(mCallbacks, context); } - // mImpl = new Camera1(mCallbacks, preview); // Attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CameraView, defStyleAttr, @@ -219,6 +218,8 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // } super.onMeasure(widthMeasureSpec, heightMeasureSpec); + if (mImpl.getView() == null) + return; // Measure the TextureView int width = getMeasuredWidth(); int height = getMeasuredHeight();