From 37a784dc3b6ee272eab00c3696193602df7e43a6 Mon Sep 17 00:00:00 2001 From: Matt Fenlon Date: Fri, 26 May 2017 07:40:03 -0700 Subject: [PATCH] Fixed orientation-related render error in preview MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added two if statements to ensure that orientation detection checks aren’t performed in edit mode. --- .../com/flurgle/camerakit/CameraView.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java index e71b8055..b3ffafb9 100644 --- a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java +++ b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java @@ -110,13 +110,15 @@ public class CameraView extends FrameLayout { setPermissions(mPermissions); setVideoQuality(mVideoQuality); - mDisplayOrientationDetector = new DisplayOrientationDetector(context) { - @Override - public void onDisplayOrientationChanged(int displayOrientation) { - mCameraImpl.setDisplayOrientation(displayOrientation); - mPreviewImpl.setDisplayOrientation(displayOrientation); - } - }; + if(!isInEditMode()){ + mDisplayOrientationDetector = new DisplayOrientationDetector(context) { + @Override + public void onDisplayOrientationChanged(int displayOrientation) { + mCameraImpl.setDisplayOrientation(displayOrientation); + mPreviewImpl.setDisplayOrientation(displayOrientation); + } + }; + } final FocusMarkerLayout focusMarkerLayout = new FocusMarkerLayout(getContext()); addView(focusMarkerLayout); @@ -137,11 +139,15 @@ public class CameraView extends FrameLayout { @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - mDisplayOrientationDetector.enable( + + if(!isInEditMode()) { + mDisplayOrientationDetector.enable( ViewCompat.isAttachedToWindow(this) - ? DisplayManagerCompat.getInstance(getContext()).getDisplay(Display.DEFAULT_DISPLAY) - : null - ); + ? DisplayManagerCompat.getInstance(getContext()) + .getDisplay(Display.DEFAULT_DISPLAY) + : null + ); + } } @Override