Skip to content

Commit

Permalink
Merge pull request googlesamples#21 from michaelcarrano/kotlin-vision…
Browse files Browse the repository at this point in the history
…-quickstart-fix

Fix bindPreviewUseCase() in CameraXLivePreviewActivity.kt to match Java implementation
  • Loading branch information
calren authored Jun 19, 2020
2 parents c66c440 + 4a178b1 commit bcb7c51
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,19 +264,19 @@ class CameraXLivePreviewActivity :
}

private fun bindPreviewUseCase() {
if (!PreferenceUtils.isCameraLiveViewportEnabled(this)) {
return
}
if (cameraProvider == null) {
return
}
if (previewUseCase != null) {
cameraProvider!!.unbind(previewUseCase)
}

previewUseCase = Preview.Builder().build()
val camera =
cameraProvider!!.bindToLifecycle(
/* lifecycleOwner= */this,
cameraSelector!!, previewUseCase
)
previewUseCase!!.setSurfaceProvider(previewView!!.createSurfaceProvider())
cameraProvider!!.bindToLifecycle(/* lifecycleOwner= */this, cameraSelector!!, previewUseCase)
}

@SuppressLint("NewApi")
Expand Down

0 comments on commit bcb7c51

Please sign in to comment.