Skip to content
Prev Previous commit
Next Next commit
Fix lint issues
  • Loading branch information
acoutts committed Apr 25, 2023
commit f338c5bddec7c53cd0314950ceb9015d360a8de2
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class Camera
CameraDeviceWrapper cameraDevice;
CameraCaptureSession captureSession;
private ImageReader pictureImageReader;
private ImageStreamReader imageStreamReader;
ImageStreamReader imageStreamReader;
/** {@link CaptureRequest.Builder} for the camera preview */
CaptureRequest.Builder previewRequestBuilder;

Expand Down Expand Up @@ -1199,7 +1199,7 @@ public void onCancel(Object o) {
});
}

private void setImageStreamImageAvailableListener(final EventChannel.EventSink imageStreamSink) {
void setImageStreamImageAvailableListener(final EventChannel.EventSink imageStreamSink) {
if (imageStreamReader == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ImageStreamReader {
*/
@VisibleForTesting
public ImageStreamReader(
ImageReader imageReader, int dartImageFormat, ImageStreamReaderUtils imageStreamReaderUtils) {
@NonNull ImageReader imageReader, int dartImageFormat, @NonNull ImageStreamReaderUtils imageStreamReaderUtils) {
this.imageReader = imageReader;
this.dartImageFormat = dartImageFormat;
this.imageStreamReaderUtils = imageStreamReaderUtils;
Expand Down Expand Up @@ -91,8 +91,8 @@ public static int computeStreamImageFormat(int dartImageFormat) {
@VisibleForTesting
public void onImageAvailable(
@NonNull Image image,
CameraCaptureProperties captureProps,
EventChannel.EventSink imageStreamSink) {
@NonNull CameraCaptureProperties captureProps,
@NonNull EventChannel.EventSink imageStreamSink) {
try {
Map<String, Object> imageBuffer = new HashMap<>();

Expand Down Expand Up @@ -138,6 +138,7 @@ public void onImageAvailable(
* @param image - the image to process.
* @return parsed map describing the image planes to be sent to dart.
*/
@NonNull
public List<Map<String, Object>> parsePlanesForYuvOrJpeg(@NonNull Image image) {
List<Map<String, Object>> planes = new ArrayList<>();

Expand All @@ -164,6 +165,7 @@ public List<Map<String, Object>> parsePlanesForYuvOrJpeg(@NonNull Image image) {
* @param image - the image to process.
* @return parsed map describing the image planes to be sent to dart.
*/
@NonNull
public List<Map<String, Object>> parsePlanesForNv21(@NonNull Image image) {
List<Map<String, Object>> planes = new ArrayList<>();

Expand All @@ -181,6 +183,7 @@ public List<Map<String, Object>> parsePlanesForNv21(@NonNull Image image) {
}

/** Returns the image reader surface. */
@NonNull
public Surface getSurface() {
return imageReader.getSurface();
}
Expand All @@ -194,9 +197,9 @@ public Surface getSurface() {
* @param handler is generally the background handler of the camera as {@link Handler}
*/
public void subscribeListener(
CameraCaptureProperties captureProps,
EventChannel.EventSink imageStreamSink,
Handler handler) {
@NonNull CameraCaptureProperties captureProps,
@NonNull EventChannel.EventSink imageStreamSink,
@NonNull Handler handler) {
imageReader.setOnImageAvailableListener(
reader -> {
Image image = reader.acquireNextImage();
Expand All @@ -212,7 +215,7 @@ public void subscribeListener(
*
* @param handler is generally the background handler of the camera
*/
public void removeListener(Handler handler) {
public void removeListener(@NonNull Handler handler) {
imageReader.setOnImageAvailableListener(null, handler);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class ImageStreamReaderUtils {
*
* <p>https://github.com/googlesamples/mlkit/blob/master/android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/BitmapUtils.java
*/
public ByteBuffer yuv420ThreePlanesToNV21(Image.Plane[] yuv420888planes, int width, int height) {
@NonNull
public ByteBuffer yuv420ThreePlanesToNV21(@NonNull Image.Plane[] yuv420888planes, int width, int height) {
int imageSize = width * height;
byte[] out = new byte[imageSize + 2 * (imageSize / 4)];

Expand Down