minor code style cleanup

This commit is contained in:
tibbi 2018-06-05 23:16:34 +02:00
parent 045328daa3
commit ea640f96ca
1 changed files with 9 additions and 7 deletions

View File

@ -209,7 +209,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
} }
private val imageAvailableListener = ImageReader.OnImageAvailableListener { reader -> private val imageAvailableListener = ImageReader.OnImageAvailableListener { reader ->
val buffer = reader.acquireNextImage().planes[0].buffer val buffer = reader.acquireNextImage().planes.first().buffer
val bytes = ByteArray(buffer.remaining()) val bytes = ByteArray(buffer.remaining())
buffer.get(bytes) buffer.get(bytes)
PhotoProcessor(mActivity, mTargetUri, mRotationAtCapture, getJPEGOrientation(), mUseFrontCamera).execute(bytes) PhotoProcessor(mActivity, mTargetUri, mRotationAtCapture, getJPEGOrientation(), mUseFrontCamera).execute(bytes)
@ -278,9 +278,11 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
mPreviewSize = chooseOptimalSize(outputSizes, rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth, maxPreviewHeight, currentResolution) mPreviewSize = chooseOptimalSize(outputSizes, rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth, maxPreviewHeight, currentResolution)
mTextureView.setAspectRatio(mPreviewSize!!.height, mPreviewSize!!.width) mTextureView.setAspectRatio(mPreviewSize!!.height, mPreviewSize!!.width)
mIsFlashSupported = characteristics.get(CameraCharacteristics.FLASH_INFO_AVAILABLE) ?: false characteristics.apply {
mIsZoomSupported = characteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM) ?: 0f > 0f mIsFlashSupported = get(CameraCharacteristics.FLASH_INFO_AVAILABLE) ?: false
mIsFocusSupported = characteristics.get(CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES).size > 1 mIsZoomSupported = get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM) ?: 0f > 0f
mIsFocusSupported = get(CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES).size > 1
}
mActivity.setFlashAvailable(mIsFlashSupported) mActivity.setFlashAvailable(mIsFlashSupported)
return return
} }
@ -304,9 +306,9 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
} }
return when { return when {
bigEnough.size > 0 -> bigEnough.minBy { it.width * it.height }!! bigEnough.isNotEmpty() -> bigEnough.minBy { it.width * it.height }!!
notBigEnough.size > 0 -> notBigEnough.maxBy { it.width * it.height }!! notBigEnough.isNotEmpty() -> notBigEnough.maxBy { it.width * it.height }!!
else -> choices[0] else -> choices.first()
} }
} }