show some exception messages publicly to speed up the glitch fixes

This commit is contained in:
tibbi 2018-06-18 22:43:42 +02:00
parent 335529ccbb
commit c6dfeb97b7
1 changed files with 11 additions and 4 deletions

View File

@ -121,6 +121,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
val cameraCharacteristics = try {
getCameraCharacteristics(activity.config.lastUsedCamera)
} catch (e: IllegalArgumentException) {
mActivity.showErrorToast("Get camera characteristics $e")
null
}
@ -209,12 +210,15 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
@SuppressLint("MissingPermission")
private fun openCamera(width: Int, height: Int) {
try {
setupCameraOutputs(width, height)
if (!mCameraOpenCloseLock.tryAcquire(2500, TimeUnit.MILLISECONDS)) {
throw RuntimeException("Time out waiting to lock camera opening.")
mActivity.runOnUiThread {
setupCameraOutputs(width, height)
if (!mCameraOpenCloseLock.tryAcquire(2500, TimeUnit.MILLISECONDS)) {
throw RuntimeException("Time out waiting to lock camera opening.")
}
getCameraManager().openCamera(mCameraId, cameraStateCallback, mBackgroundHandler)
}
getCameraManager().openCamera(mCameraId, cameraStateCallback, mBackgroundHandler)
} catch (e: Exception) {
mActivity.showErrorToast("Open camera $e")
}
}
@ -378,6 +382,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
return
}
} catch (e: Exception) {
mActivity.showErrorToast("Setup camera outputs $e")
}
}
@ -481,6 +486,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
mCameraDevice!!.createCaptureSession(Arrays.asList(surface, mImageReader!!.surface), stateCallback, null)
}
} catch (e: Exception) {
mActivity.showErrorToast("Create preview $e")
}
}
@ -586,6 +592,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
capture(captureBuilder.build(), captureCallback, null)
}
} catch (e: CameraAccessException) {
mActivity.showErrorToast("Capture picture $e")
}
}