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:
Mateusz Mędrek
2023-10-03 11:33:48 +02:00
committed by GitHub
parent b24b1c808f
commit 62e786ad04
14 changed files with 220 additions and 19 deletions

View File

@@ -1,5 +1,6 @@
apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply plugin: "kotlin-android"
import com.android.build.OutputFile

View File

@@ -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
)
)
}
}

View File

@@ -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());
}
}

View File

@@ -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")
}
}