From 21e058836e6d0678e1a42df659974a6c6ca13cf6 Mon Sep 17 00:00:00 2001 From: Dylan McIntyre Date: Thu, 9 Mar 2017 20:25:11 -0500 Subject: [PATCH] camera start and toggle async for no lag --- .../java/com/flurgle/camerakit/CameraView.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java index 9044ef91..90be2924 100644 --- a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java +++ b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java @@ -149,7 +149,12 @@ public class CameraView extends FrameLayout { public void start() { int permissionCheck = ContextCompat.checkSelfPermission(getContext(), Manifest.permission.CAMERA); if (permissionCheck == PackageManager.PERMISSION_GRANTED) { - mCameraImpl.start(); + new Thread(new Runnable() { + @Override + public void run() { + mCameraImpl.start(); + } + }).start(); } else { requestCameraPermission(); } @@ -159,9 +164,15 @@ public class CameraView extends FrameLayout { mCameraImpl.stop(); } - public void setFacing(@Facing int facing) { + public void setFacing(@Facing final int facing) { this.mFacing = facing; - mCameraImpl.setFacing(facing); + + new Thread(new Runnable() { + @Override + public void run() { + mCameraImpl.setFacing(facing); + } + }).start(); } public void setFlash(@Flash int flash) {