fix: Initialize Plugins in a static
block of ReactPackage (#2039)
* fix: Initialize Plugins in a `static` block of ReactPackage * fix: Also register FP Plugins in Example
This commit is contained in:
parent
07027d8010
commit
3929c0ac46
@ -88,7 +88,7 @@ import com.mrousavy.camera.frameprocessor.FrameProcessorPluginRegistry;
|
||||
|
||||
public class FaceDetectorFrameProcessorPluginPackage implements ReactPackage {
|
||||
// highlight-start
|
||||
FaceDetectorFrameProcessorPluginPackage() {
|
||||
static {
|
||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("detectFaces", options -> new FaceDetectorFrameProcessorPlugin(options));
|
||||
}
|
||||
// highlight-end
|
||||
@ -158,11 +158,13 @@ import com.mrousavy.camera.frameprocessor.FrameProcessorPlugin
|
||||
|
||||
class FaceDetectorFrameProcessorPluginPackage : ReactPackage {
|
||||
// highlight-start
|
||||
companion object {
|
||||
init {
|
||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("detectFaces") { options ->
|
||||
FaceDetectorFrameProcessorPlugin(options)
|
||||
}
|
||||
}
|
||||
}
|
||||
// highlight-end
|
||||
|
||||
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
||||
|
@ -18,6 +18,11 @@ import com.mrousavy.camera.frameprocessor.FrameProcessorPlugin;
|
||||
import com.mrousavy.camera.frameprocessor.FrameProcessorPluginRegistry;
|
||||
|
||||
public class MainApplication extends Application implements ReactApplication {
|
||||
// Register the Frame Processor Plugins for our app
|
||||
static {
|
||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("example_plugin", options -> new ExampleFrameProcessorPlugin(options));
|
||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("example_kotlin_swift_plugin", options -> new ExampleKotlinFrameProcessorPlugin(options));
|
||||
}
|
||||
|
||||
private final ReactNativeHost mReactNativeHost =
|
||||
new DefaultReactNativeHost(this) {
|
||||
@ -64,8 +69,5 @@ public class MainApplication extends Application implements ReactApplication {
|
||||
// If you opted-in for the New Architecture, we load the native entry point for this app.
|
||||
DefaultNewArchitectureEntryPoint.load();
|
||||
}
|
||||
|
||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("example_plugin", options -> new ExampleFrameProcessorPlugin(options));
|
||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("example_kotlin_swift_plugin", options -> new ExampleKotlinFrameProcessorPlugin(options));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user