From d533b18a91c4df5b3847a6c14e74c83ad1214a29 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 10 Jun 2018 21:18:28 +0200 Subject: [PATCH] make sure the aspect ratio is always updated on the main thread --- .../com/simplemobiletools/camera/views/PreviewCameraTwo.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt b/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt index 49c18302..4c21dab3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt @@ -351,7 +351,9 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie val outputSizes = if (mIsInVideoMode) configMap.getOutputSizes(MediaRecorder::class.java) else configMap.getOutputSizes(SurfaceTexture::class.java) mPreviewSize = chooseOptimalPreviewSize(outputSizes, rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth, maxPreviewHeight, currentResolution) - mTextureView.setAspectRatio(mPreviewSize!!.height, mPreviewSize!!.width) + mActivity.runOnUiThread { + mTextureView.setAspectRatio(mPreviewSize!!.height, mPreviewSize!!.width) + } characteristics.apply { mIsFlashSupported = get(CameraCharacteristics.FLASH_INFO_AVAILABLE) ?: false mIsZoomSupported = get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM) ?: 0f > 0f