chore: Cleanup Android codebase (#2415)

This commit is contained in:
Marc Rousavy 2024-01-18 18:55:49 +01:00 committed by GitHub
parent 5c5d629936
commit bae1f52d4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 16 additions and 33 deletions

View File

@ -82,9 +82,11 @@ class CameraDevicesManager(private val reactContext: ReactApplicationContext) :
}
// Required for NativeEventEmitter, this is just a dummy implementation:
@Suppress("unused", "UNUSED_PARAMETER")
@ReactMethod
fun addListener(eventName: String) {}
@Suppress("unused", "UNUSED_PARAMETER")
@ReactMethod
fun removeListeners(count: Int) {}
}

View File

@ -1,27 +0,0 @@
package com.mrousavy.camera.extensions
import android.hardware.camera2.params.DynamicRangeProfiles
import android.os.Build
import androidx.annotation.RequiresApi
private fun Set<Long>.firstMatch(filter: Set<Long>): Long? {
filter.forEach { f ->
if (this.contains(f)) {
return f
}
}
return null
}
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
private val bestProfiles = setOf(
DynamicRangeProfiles.HDR10_PLUS,
DynamicRangeProfiles.HDR10,
DynamicRangeProfiles.HLG10
)
val DynamicRangeProfiles.bestProfile: Long?
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
get() {
return supportedProfiles.firstMatch(bestProfiles)
}

View File

@ -1,3 +0,0 @@
package com.mrousavy.camera.extensions
fun <T> List<T>.containsAny(elements: List<T>): Boolean = elements.any { element -> this.contains(element) }

View File

@ -9,6 +9,7 @@ import com.facebook.proguard.annotations.DoNotStrip;
/**
* Represents a JS Frame Processor
* @noinspection JavaJniMissingFunction
*/
public final class FrameProcessor {
/**

View File

@ -8,10 +8,10 @@ import java.util.Map;
/**
* The base class of a native Frame Processor Plugin.
*
* <p></p>
* Subclass this to create a custom Frame Processor Plugin, which can be called from a JS Frame Processor.
* Once subclassed, it needs to be registered in the VisionCamera Frame Processor
* runtime via `FrameProcessorPluginRegistry.addFrameProcessorPlugin` - ideally at app startup.
* runtime via <code>FrameProcessorPluginRegistry.addFrameProcessorPlugin</code> - ideally at app startup.
* See: <a href="https://react-native-vision-camera.com/docs/guides/frame-processors-plugins-android">Creating Frame Processor Plugins (Android)</a>
* for more information

View File

@ -14,6 +14,17 @@ public class FrameProcessorPluginRegistry {
private static final Map<String, PluginInitializer> Plugins = new HashMap<>();
private static final String TAG = "FrameProcessorPluginRegistry";
/**
* Adds the given Plugin to the Frame Processor Plugin Registry.
* The given Plugin might then be initialized later from JavaScript, through the <code>VisionCameraProxy</code>.
* The returned Plugin will be deallocated once the value is no longer used in JavaScript.
* <p></p>
* This function can be called from any Thread, and should be called as soon as possible - ideally on app start
* or in a static initializer.
*
* @param name The name of the plugin which will be used to find the plugin from the JS side.
* @param pluginInitializer An initializer function to create instances of this Plugin.
*/
@DoNotStrip
@Keep
public static void addFrameProcessorPlugin(String name, PluginInitializer pluginInitializer) {

View File

@ -23,7 +23,6 @@ public class VisionCameraScheduler {
@DoNotStrip
private void scheduleTrigger() {
CameraQueues.CameraQueue videoQueue = CameraQueues.Companion.getVideoQueue();
// TODO: Make sure post(this::trigger) works.
videoQueue.getHandler().post(this::trigger);
}
}