Skip to content

Instantly share code, notes, and snippets.

@deepak140596
Created August 28, 2019 13:51
Show Gist options
  • Save deepak140596/75c3cfde8e5a1cecb3fa2244ef7a84d1 to your computer and use it in GitHub Desktop.
Save deepak140596/75c3cfde8e5a1cecb3fa2244ef7a84d1 to your computer and use it in GitHub Desktop.
override fun onCreate(savedInstanceState: Bundle?) {
...
// Add this at the end of onCreate function
viewFinder = findViewById(R.id.view_finder)
// Request camera permissions
if (allPermissionsGranted()) {
viewFinder.post { startCamera() }
} else {
ActivityCompat.requestPermissions(
this, REQUIRED_PERMISSIONS, REQUEST_CODE_PERMISSIONS)
}
// Every time the provided texture view changes, recompute layout
viewFinder.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ ->
updateTransform()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment