From 122a2cb17425d087e371aec3e62ed92a9672bdb1 Mon Sep 17 00:00:00 2001 From: Tim H Date: Thu, 5 Oct 2017 18:32:16 +0200 Subject: [PATCH] apply some of the changes suggested by natario1 --- .../otaliastudios/cameraview/CameraController.java | 2 +- .../com/otaliastudios/cameraview/CameraView.java | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java index 32e1bf63..3ddcf32f 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java @@ -138,8 +138,8 @@ abstract class CameraController implements CameraPreview.SurfaceCallback { LOG.i("Stop immediately. Stopped. State is:", ss()); } catch (Exception e) { // Do nothing. + LOG.i("Stop immediately. Exception while stopping.", e); mState = STATE_STOPPED; - mCameraCallbacks.onError("Stop immediately. Exception while stopping.", e); } } diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java index 2ddfd678..7e56dc54 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java @@ -1569,10 +1569,15 @@ public class CameraView extends FrameLayout { LOG.e(message, cause); // redirect - CameraException cameraException = new CameraException(message, cause); - for (CameraListener listener : mListeners) { - listener.onError(cameraException); - } + final CameraException cameraException = new CameraException(message, cause); + mUiHandler.post(new Runnable() { + @Override + public void run() { + for (CameraListener listener : mListeners) { + listener.onError(cameraException); + } + } + }); } }