react-native-rectangle-doc-scanner 3.174.0 → 3.176.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.
|
@@ -145,6 +145,7 @@ class CameraController(
|
|
|
145
145
|
Log.d(TAG, "[BIND] PreviewView.surfaceProvider: ${previewView.surfaceProvider}")
|
|
146
146
|
Log.d(TAG, "[BIND] PreviewView attached to window: ${previewView.isAttachedToWindow}")
|
|
147
147
|
Log.d(TAG, "[BIND] PreviewView size: ${previewView.width}x${previewView.height}")
|
|
148
|
+
Log.d(TAG, "[BIND] PreviewView implementationMode: ${previewView.implementationMode}")
|
|
148
149
|
// Unbind all use cases before rebinding
|
|
149
150
|
Log.d(TAG, "[BIND] Unbinding all existing use cases...")
|
|
150
151
|
cameraProvider.unbindAll()
|
|
@@ -167,10 +168,15 @@ class CameraController(
|
|
|
167
168
|
Log.d(TAG, "[BIND] Setting surface provider to previewView...")
|
|
168
169
|
Log.d(TAG, "[BIND] PreviewView: $previewView")
|
|
169
170
|
Log.d(TAG, "[BIND] PreviewView.surfaceProvider: ${previewView.surfaceProvider}")
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
// TextureView(Compatibility) 모드에서는 SurfaceProvider를 먼저 지정해도 순서 문제가 없다.
|
|
172
|
+
// PERFORMANCE 모드(SurfaceView)에서는 SurfaceOrderQuirk 대응을 위해 바인딩 이후에 지정한다.
|
|
173
|
+
if (previewView.implementationMode == PreviewView.ImplementationMode.COMPATIBLE) {
|
|
174
|
+
preview.setSurfaceProvider(previewView.surfaceProvider)
|
|
175
|
+
Log.d(TAG, "[BIND] Surface provider set immediately (COMPATIBLE mode)")
|
|
176
|
+
} else {
|
|
177
|
+
preview.setSurfaceProvider(previewView.surfaceProvider)
|
|
178
|
+
Log.d(TAG, "[BIND] Surface provider set after binding (PERFORMANCE mode)")
|
|
179
|
+
}
|
|
174
180
|
|
|
175
181
|
// Restore torch state if it was enabled
|
|
176
182
|
if (torchEnabled) {
|
|
@@ -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() {
|
package/package.json
CHANGED