docs: Add Kotlin & Swift FP plugins examples (#1902)
* chore(docs): add Kotlin FP example * chore(docs): add Swift FP plugin
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
apply plugin: "com.android.application"
|
||||
apply plugin: "com.facebook.react"
|
||||
apply plugin: "kotlin-android"
|
||||
|
||||
import com.android.build.OutputFile
|
||||
|
||||
|
@@ -0,0 +1,35 @@
|
||||
package com.mrousavy.camera.example
|
||||
|
||||
import android.util.Log
|
||||
import com.mrousavy.camera.frameprocessor.Frame
|
||||
import com.mrousavy.camera.frameprocessor.FrameProcessorPlugin
|
||||
|
||||
class ExampleKotlinFrameProcessorPlugin: FrameProcessorPlugin() {
|
||||
override fun callback(frame: Frame, params: Map<String, Any>?): Any? {
|
||||
if (params == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
val image = frame.image
|
||||
Log.d(
|
||||
"ExampleKotlinPlugin",
|
||||
image.width.toString() + " x " + image.height + " Image with format #" + image.format + ". Logging " + params.size + " parameters:"
|
||||
)
|
||||
|
||||
for (key in params.keys) {
|
||||
val value = params[key]
|
||||
Log.d("ExampleKotlinPlugin", " -> " + if (value == null) "(null)" else value.toString() + " (" + value.javaClass.name + ")")
|
||||
}
|
||||
|
||||
return hashMapOf<String, Any>(
|
||||
"example_str" to "KotlinTest",
|
||||
"example_bool" to false,
|
||||
"example_double" to 6.7,
|
||||
"example_array" to arrayListOf<Any>(
|
||||
"Good bye",
|
||||
false,
|
||||
21.37
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
@@ -66,5 +66,6 @@ public class MainApplication extends Application implements ReactApplication {
|
||||
}
|
||||
|
||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("example_plugin", options -> new ExampleFrameProcessorPlugin());
|
||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("example_kotlin_swift_plugin", options -> new ExampleKotlinFrameProcessorPlugin());
|
||||
}
|
||||
}
|
||||
|
@@ -15,5 +15,6 @@ buildscript {
|
||||
dependencies {
|
||||
classpath('com.android.tools.build:gradle:7.4.1')
|
||||
classpath("com.facebook.react:react-native-gradle-plugin")
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user