From bea4aa8bb610fafb8b7f35d7f4d5bf396c5b752a Mon Sep 17 00:00:00 2001 From: Christopher Janietz Date: Mon, 28 Mar 2022 13:22:27 +0200 Subject: [PATCH] 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 --- .../camera/frameprocessor/FrameProcessorRuntimeManager.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/mrousavy/camera/frameprocessor/FrameProcessorRuntimeManager.kt b/android/src/main/java/com/mrousavy/camera/frameprocessor/FrameProcessorRuntimeManager.kt index bb1781b..ebad5f6 100644 --- a/android/src/main/java/com/mrousavy/camera/frameprocessor/FrameProcessorRuntimeManager.kt +++ b/android/src/main/java/com/mrousavy/camera/frameprocessor/FrameProcessorRuntimeManager.kt @@ -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(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) }