react-native-rectangle-doc-scanner 3.151.0 → 3.152.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.
|
@@ -62,7 +62,7 @@ class CameraView(context: Context) : FrameLayout(context), LifecycleOwner {
|
|
|
62
62
|
addView(overlayView)
|
|
63
63
|
|
|
64
64
|
Log.d(TAG, "CameraView initialized")
|
|
65
|
-
lifecycleRegistry.
|
|
65
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/**
|
|
@@ -91,7 +91,8 @@ class CameraView(context: Context) : FrameLayout(context), LifecycleOwner {
|
|
|
91
91
|
fun stopCamera() {
|
|
92
92
|
cameraProvider?.unbindAll()
|
|
93
93
|
if (lifecycleRegistry.currentState != Lifecycle.State.DESTROYED) {
|
|
94
|
-
lifecycleRegistry.
|
|
94
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
|
95
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_STOP)
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -115,6 +116,11 @@ class CameraView(context: Context) : FrameLayout(context), LifecycleOwner {
|
|
|
115
116
|
// Unbind all before rebinding
|
|
116
117
|
provider.unbindAll()
|
|
117
118
|
|
|
119
|
+
if (lifecycleRegistry.currentState != Lifecycle.State.DESTROYED) {
|
|
120
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
|
|
121
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
|
122
|
+
}
|
|
123
|
+
|
|
118
124
|
// Preview use case
|
|
119
125
|
preview = Preview.Builder()
|
|
120
126
|
.build()
|
|
@@ -222,7 +228,7 @@ class CameraView(context: Context) : FrameLayout(context), LifecycleOwner {
|
|
|
222
228
|
override fun onDetachedFromWindow() {
|
|
223
229
|
super.onDetachedFromWindow()
|
|
224
230
|
stopCamera()
|
|
225
|
-
lifecycleRegistry.
|
|
231
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
226
232
|
if (!cameraExecutor.isShutdown) {
|
|
227
233
|
cameraExecutor.shutdown()
|
|
228
234
|
}
|
|
@@ -77,14 +77,14 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
77
77
|
setupCamera()
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
lifecycleRegistry.
|
|
80
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE)
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
private fun setupCamera() {
|
|
84
84
|
try {
|
|
85
85
|
// Move to STARTED state first
|
|
86
|
-
if (lifecycleRegistry.currentState
|
|
87
|
-
lifecycleRegistry.
|
|
86
|
+
if (lifecycleRegistry.currentState != Lifecycle.State.DESTROYED) {
|
|
87
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
cameraController = CameraController(context, this, previewView)
|
|
@@ -95,7 +95,7 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
95
95
|
|
|
96
96
|
// Move to RESUMED state before starting camera
|
|
97
97
|
if (lifecycleRegistry.currentState != Lifecycle.State.DESTROYED) {
|
|
98
|
-
lifecycleRegistry.
|
|
98
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
cameraController?.startCamera(isUsingFrontCamera, true)
|
|
@@ -106,7 +106,7 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
106
106
|
Log.d(TAG, "Camera setup completed")
|
|
107
107
|
} catch (e: Exception) {
|
|
108
108
|
Log.e(TAG, "Failed to setup camera", e)
|
|
109
|
-
lifecycleRegistry.
|
|
109
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE)
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -371,7 +371,8 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
371
371
|
lifecycleRegistry.currentState = Lifecycle.State.STARTED
|
|
372
372
|
}
|
|
373
373
|
if (lifecycleRegistry.currentState != Lifecycle.State.DESTROYED) {
|
|
374
|
-
lifecycleRegistry.
|
|
374
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
|
|
375
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
|
375
376
|
}
|
|
376
377
|
|
|
377
378
|
cameraController?.startCamera(isUsingFrontCamera, true)
|
|
@@ -385,9 +386,10 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
385
386
|
cameraController?.stopCamera()
|
|
386
387
|
overlayView.setRectangle(null, overlayColor)
|
|
387
388
|
stableCounter = 0
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
389
|
+
if (lifecycleRegistry.currentState != Lifecycle.State.DESTROYED) {
|
|
390
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
|
391
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_STOP)
|
|
392
|
+
}
|
|
391
393
|
} else {
|
|
392
394
|
Log.d(TAG, "Cannot stop camera while capturing")
|
|
393
395
|
}
|
|
@@ -420,7 +422,7 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
420
422
|
private fun performCleanup() {
|
|
421
423
|
Log.d(TAG, "Performing cleanup")
|
|
422
424
|
cameraController?.stopCamera()
|
|
423
|
-
lifecycleRegistry.
|
|
425
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
424
426
|
cameraController?.shutdown()
|
|
425
427
|
scope.cancel()
|
|
426
428
|
}
|
package/package.json
CHANGED