fix: Fix issue with resolving camera view in Modal (#928)

* Fix issue with resolving camera view from frame processor for react-native Modal

* Add missing import of UIManagerHelper
This commit is contained in:
Christopher Janietz 2022-03-28 13:22:27 +02:00 committed by GitHub
parent 65d4d46f6a
commit bea4aa8bb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ import com.facebook.jni.HybridData
import com.facebook.proguard.annotations.DoNotStrip
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.turbomodule.core.CallInvokerHolderImpl
import com.facebook.react.uimanager.UIManagerHelper
import com.mrousavy.camera.CameraView
import com.mrousavy.camera.ViewNotFoundError
import java.lang.ref.WeakReference
@ -60,7 +61,8 @@ class FrameProcessorRuntimeManager(context: ReactApplicationContext, frameProces
@Keep
fun findCameraViewById(viewId: Int): CameraView {
Log.d(TAG, "Finding view $viewId...")
val view = mContext?.get()?.currentActivity?.findViewById<CameraView>(viewId)
val ctx = mContext?.get()
val view = if (ctx != null) UIManagerHelper.getUIManager(ctx, viewId)?.resolveView(viewId) as CameraView? else null
Log.d(TAG, if (view != null) "Found view $viewId!" else "Couldn't find view $viewId!")
return view ?: throw ViewNotFoundError(viewId)
}