mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Use java.util.function.Consumer for event listener.
This commit is contained in:
@@ -13,6 +13,7 @@ import java.io.OutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.function.Consumer;
|
||||
import org.opencv.core.Core;
|
||||
|
||||
public class CameraServerJNI {
|
||||
@@ -164,7 +165,7 @@ public class CameraServerJNI {
|
||||
//
|
||||
// Listener Functions
|
||||
//
|
||||
public static native int addListener(VideoListenerFunction listener,
|
||||
public static native int addListener(Consumer<VideoEvent> listener,
|
||||
int eventMask, boolean immediateNotify);
|
||||
|
||||
public static native void removeListener(int handle);
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/// An event listener. This calls back to a desigated callback function when
|
||||
/// an event matching the specified mask is generated by the library.
|
||||
public class VideoListener {
|
||||
@@ -15,7 +17,7 @@ public class VideoListener {
|
||||
/// @param eventMask Bitmask of VideoEvent.Type values
|
||||
/// @param immediateNotify Whether callback should be immediately called with
|
||||
/// a representative set of events for the current library state.
|
||||
public VideoListener(VideoListenerFunction listener, int eventMask,
|
||||
public VideoListener(Consumer<VideoEvent> listener, int eventMask,
|
||||
boolean immediateNotify) {
|
||||
m_handle = CameraServerJNI.addListener(listener, eventMask, immediateNotify);
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
public interface VideoListenerFunction {
|
||||
void apply(VideoEvent event);
|
||||
}
|
||||
Reference in New Issue
Block a user