react-native-rectangle-doc-scanner 3.175.0 → 3.177.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.
|
@@ -119,21 +119,42 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
119
119
|
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
|
|
120
120
|
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
|
121
121
|
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
// Initialize camera immediately or on next layout
|
|
123
|
+
initializeCameraWhenReady()
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private fun initializeCameraWhenReady() {
|
|
127
|
+
// If view is already laid out, start camera immediately
|
|
128
|
+
if (width > 0 && height > 0) {
|
|
129
|
+
Log.d(TAG, "[INIT] View already laid out, starting camera immediately")
|
|
130
|
+
Log.d(TAG, "[INIT] View: width=$width, height=$height")
|
|
131
|
+
Log.d(TAG, "[INIT] PreviewView: width=${previewView.width}, height=${previewView.height}")
|
|
132
|
+
setupCamera()
|
|
133
|
+
startCamera()
|
|
134
|
+
} else {
|
|
135
|
+
// Otherwise, wait for layout
|
|
136
|
+
Log.d(TAG, "[INIT] View not laid out yet, waiting for layout")
|
|
137
|
+
post {
|
|
138
|
+
if (width > 0 && height > 0) {
|
|
139
|
+
Log.d(TAG, "[INIT] View laid out after post: width=$width, height=$height")
|
|
130
140
|
setupCamera()
|
|
131
141
|
startCamera()
|
|
132
142
|
} else {
|
|
133
|
-
|
|
143
|
+
// Fallback: use ViewTreeObserver if still not ready
|
|
144
|
+
Log.d(TAG, "[INIT] Still not laid out, using ViewTreeObserver")
|
|
145
|
+
viewTreeObserver.addOnGlobalLayoutListener(object : android.view.ViewTreeObserver.OnGlobalLayoutListener {
|
|
146
|
+
override fun onGlobalLayout() {
|
|
147
|
+
if (width > 0 && height > 0) {
|
|
148
|
+
viewTreeObserver.removeOnGlobalLayoutListener(this)
|
|
149
|
+
Log.d(TAG, "[INIT] View laid out via observer: width=$width, height=$height")
|
|
150
|
+
setupCamera()
|
|
151
|
+
startCamera()
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
})
|
|
134
155
|
}
|
|
135
156
|
}
|
|
136
|
-
}
|
|
157
|
+
}
|
|
137
158
|
}
|
|
138
159
|
|
|
139
160
|
private fun setupCamera() {
|
|
@@ -416,6 +437,18 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
416
437
|
Log.d(TAG, "[START_CAMERA] isTorchEnabled: $isTorchEnabled")
|
|
417
438
|
Log.d(TAG, "[START_CAMERA] CameraController: $cameraController")
|
|
418
439
|
|
|
440
|
+
// Force PreviewView visibility and layout
|
|
441
|
+
previewView.post {
|
|
442
|
+
Log.d(TAG, "[START_CAMERA] Forcing PreviewView visibility and layout...")
|
|
443
|
+
previewView.visibility = View.VISIBLE
|
|
444
|
+
previewView.alpha = 1.0f
|
|
445
|
+
previewView.requestLayout()
|
|
446
|
+
previewView.invalidate()
|
|
447
|
+
Log.d(TAG, "[START_CAMERA] PreviewView state - visible: ${previewView.visibility == View.VISIBLE}, alpha: ${previewView.alpha}")
|
|
448
|
+
Log.d(TAG, "[START_CAMERA] PreviewView state - width: ${previewView.width}, height: ${previewView.height}")
|
|
449
|
+
Log.d(TAG, "[START_CAMERA] PreviewView state - hasWindowFocus: ${previewView.hasWindowFocus()}")
|
|
450
|
+
}
|
|
451
|
+
|
|
419
452
|
lastDetectionTimestamp = 0L
|
|
420
453
|
cameraController?.onFrameAnalyzed = { rectangle, imageWidth, imageHeight ->
|
|
421
454
|
handleDetectionResult(rectangle, imageWidth, imageHeight)
|
package/package.json
CHANGED