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 {
|
public class FaceDetectorFrameProcessorPluginPackage implements ReactPackage {
|
||||||
// highlight-start
|
// highlight-start
|
||||||
FaceDetectorFrameProcessorPluginPackage() {
|
static {
|
||||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("detectFaces", options -> new FaceDetectorFrameProcessorPlugin(options));
|
FrameProcessorPluginRegistry.addFrameProcessorPlugin("detectFaces", options -> new FaceDetectorFrameProcessorPlugin(options));
|
||||||
}
|
}
|
||||||
// highlight-end
|
// highlight-end
|
||||||
@ -158,9 +158,11 @@ import com.mrousavy.camera.frameprocessor.FrameProcessorPlugin
|
|||||||
|
|
||||||
class FaceDetectorFrameProcessorPluginPackage : ReactPackage {
|
class FaceDetectorFrameProcessorPluginPackage : ReactPackage {
|
||||||
// highlight-start
|
// highlight-start
|
||||||
init {
|
companion object {
|
||||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("detectFaces") { options ->
|
init {
|
||||||
FaceDetectorFrameProcessorPlugin(options)
|
FrameProcessorPluginRegistry.addFrameProcessorPlugin("detectFaces") { options ->
|
||||||
|
FaceDetectorFrameProcessorPlugin(options)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// highlight-end
|
// highlight-end
|
||||||
|
@ -18,6 +18,11 @@ import com.mrousavy.camera.frameprocessor.FrameProcessorPlugin;
|
|||||||
import com.mrousavy.camera.frameprocessor.FrameProcessorPluginRegistry;
|
import com.mrousavy.camera.frameprocessor.FrameProcessorPluginRegistry;
|
||||||
|
|
||||||
public class MainApplication extends Application implements ReactApplication {
|
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 =
|
private final ReactNativeHost mReactNativeHost =
|
||||||
new DefaultReactNativeHost(this) {
|
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.
|
// If you opted-in for the New Architecture, we load the native entry point for this app.
|
||||||
DefaultNewArchitectureEntryPoint.load();
|
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