Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2024-08-08 12:49:31 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ee336cd0c9119b63e30154d8285ece0232de1681
ee336cd0
1 parent
64f57c27
fix bug with unbinding camera observers; release scanner on stop
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt
View file @
ee336cd
...
...
@@ -422,14 +422,27 @@ class MobileScanner(
}
val owner = activity as LifecycleOwner
camera?.cameraInfo?.torchState?.removeObservers(owner)
// Release the camera observers first.
camera?.cameraInfo?.let {
it.torchState.removeObservers(owner)
it.zoomState.removeObservers(owner)
it.cameraState.removeObservers(owner)
}
// Unbind the camera use cases, the preview is a use case.
// The camera will be closed when the last use case is unbound.
cameraProvider?.unbindAll()
textureEntry?.release()
cameraProvider = null
camera = null
preview = null
// Release the texture for the preview.
textureEntry?.release()
textureEntry = null
cameraProvider = null
// Release the scanner.
scanner?.close()
scanner = null
lastScanned = null
}
private fun isStopped() = camera == null && preview == null
...
...
Please
register
or
login
to post a comment