From 36560d950318a923c47b0785c7fbc18b9156f052 Mon Sep 17 00:00:00 2001 From: Ferdian Sulaiman Date: Tue, 17 Jul 2018 11:56:25 +0700 Subject: [PATCH] move all next steps in start() to handler postdelayed --- .../google/android/cameraview/demo/MainActivity.java | 5 ++++- .../api14/com/google/android/cameraview/Camera1.java | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/demo/src/main/java/com/google/android/cameraview/demo/MainActivity.java b/demo/src/main/java/com/google/android/cameraview/demo/MainActivity.java index 99119475..7b9f90d7 100644 --- a/demo/src/main/java/com/google/android/cameraview/demo/MainActivity.java +++ b/demo/src/main/java/com/google/android/cameraview/demo/MainActivity.java @@ -107,8 +107,11 @@ public void onClick(View v) { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - mCameraView = (CameraView) findViewById(R.id.camera); + mCameraView = findViewById(R.id.camera); if (mCameraView != null) { + mCameraView.setKycImageType("SELFIE_ID"); + mCameraView.setTitleText("Pastikan KTP anda sejajar dengan\n" + + "garis panduan"); mCameraView.addCallback(mCallback); } FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.take_picture); diff --git a/library/src/main/api14/com/google/android/cameraview/Camera1.java b/library/src/main/api14/com/google/android/cameraview/Camera1.java index 8a2e0d16..02493604 100644 --- a/library/src/main/api14/com/google/android/cameraview/Camera1.java +++ b/library/src/main/api14/com/google/android/cameraview/Camera1.java @@ -90,11 +90,6 @@ public void onSurfaceChanged() { boolean start() { chooseCamera(); openCamera(); - if (mPreview.isReady()) { - setUpPreview(); - } - mShowingPreview = true; - mCamera.startPreview(); return true; } @@ -329,6 +324,11 @@ public void run() { adjustCameraParameters(); mCamera.setDisplayOrientation(calcDisplayOrientation(mDisplayOrientation)); mCallback.onCameraOpened(); + if (mPreview.isReady()) { + setUpPreview(); + } + mShowingPreview = true; + mCamera.startPreview(); } }, delay);