catch exceptions thrown at saving images

This commit is contained in:
tibbi 2018-06-10 11:46:53 +02:00
parent 104eca5196
commit fc058e2f05
1 changed files with 7 additions and 4 deletions

View File

@ -251,10 +251,13 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
}
private val imageAvailableListener = ImageReader.OnImageAvailableListener { reader ->
val buffer = reader.acquireNextImage().planes.first().buffer
val bytes = ByteArray(buffer.remaining())
buffer.get(bytes)
PhotoProcessor(mActivity, mTargetUri, mRotationAtCapture, getJPEGOrientation(), mUseFrontCamera).execute(bytes)
try {
val buffer = reader.acquireNextImage().planes.first().buffer
val bytes = ByteArray(buffer.remaining())
buffer.get(bytes)
PhotoProcessor(mActivity, mTargetUri, mRotationAtCapture, getJPEGOrientation(), mUseFrontCamera).execute(bytes)
} catch (e: Exception) {
}
}
private fun getJPEGOrientation(): Int {