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();