react-native-rectangle-doc-scanner 3.150.0 → 3.151.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -82,14 +82,22 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
82
82
 
83
83
  private fun setupCamera() {
84
84
  try {
85
+ // Move to STARTED state first
86
+ if (lifecycleRegistry.currentState == Lifecycle.State.CREATED) {
87
+ lifecycleRegistry.currentState = Lifecycle.State.STARTED
88
+ }
89
+
85
90
  cameraController = CameraController(context, this, previewView)
86
91
  cameraController?.onFrameAnalyzed = { rectangle, imageWidth, imageHeight ->
87
92
  handleDetectionResult(rectangle, imageWidth, imageHeight)
88
93
  }
89
94
  lastDetectionTimestamp = 0L
95
+
96
+ // Move to RESUMED state before starting camera
90
97
  if (lifecycleRegistry.currentState != Lifecycle.State.DESTROYED) {
91
98
  lifecycleRegistry.currentState = Lifecycle.State.RESUMED
92
99
  }
100
+
93
101
  cameraController?.startCamera(isUsingFrontCamera, true)
94
102
  if (isTorchEnabled) {
95
103
  cameraController?.setTorchEnabled(true)
@@ -357,11 +365,19 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
357
365
  cameraController?.onFrameAnalyzed = { rectangle, imageWidth, imageHeight ->
358
366
  handleDetectionResult(rectangle, imageWidth, imageHeight)
359
367
  }
368
+
369
+ // Ensure proper lifecycle state before starting camera
370
+ if (lifecycleRegistry.currentState == Lifecycle.State.CREATED) {
371
+ lifecycleRegistry.currentState = Lifecycle.State.STARTED
372
+ }
373
+ if (lifecycleRegistry.currentState != Lifecycle.State.DESTROYED) {
374
+ lifecycleRegistry.currentState = Lifecycle.State.RESUMED
375
+ }
376
+
360
377
  cameraController?.startCamera(isUsingFrontCamera, true)
361
378
  if (isTorchEnabled) {
362
379
  cameraController?.setTorchEnabled(true)
363
380
  }
364
- lifecycleRegistry.currentState = Lifecycle.State.RESUMED
365
381
  }
366
382
 
367
383
  fun stopCamera() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.150.0",
3
+ "version": "3.151.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",