From f25e5bc826d50fcf9d62f6d2addec349b0d4f8a8 Mon Sep 17 00:00:00 2001 From: Dylan McIntyre Date: Sat, 21 Jan 2017 19:50:38 -0500 Subject: [PATCH] setup cameralistener middleware --- build.gradle | 2 +- .../com/flurgle/camerakit/CameraListener.java | 4 -- .../com/flurgle/camerakit/CameraView.java | 43 ++++++++++++++++++- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index a3330d48..b1557280 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.0' + classpath 'com.android.tools.build:gradle:2.3.0-beta1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraListener.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraListener.java index a2a48b73..915cb105 100644 --- a/camerakit/src/main/java/com/flurgle/camerakit/CameraListener.java +++ b/camerakit/src/main/java/com/flurgle/camerakit/CameraListener.java @@ -12,10 +12,6 @@ public abstract class CameraListener { } - public void onPictureTaken(File picture) { - - } - public void onPictureTaken(byte[] picture) { } diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java index cec010f2..de62fb36 100644 --- a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java +++ b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java @@ -15,6 +15,7 @@ import android.util.AttributeSet; import android.view.Display; import android.widget.FrameLayout; +import java.io.File; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -206,9 +207,13 @@ public class CameraView extends FrameLayout { this.mPictureMode = pictureMode; } + public void setCropOutput(boolean cropOutput) { + this.mCropOutput = cropOutput; + } + public void setCameraListener(CameraListener cameraListener) { - this.mCameraListener = cameraListener; - mCameraImpl.setCameraListener(cameraListener); + this.mCameraListener = new CameraListenerMiddleWare(cameraListener); + mCameraImpl.setCameraListener(mCameraListener); } public void capturePicture() { @@ -272,4 +277,38 @@ public class CameraView extends FrameLayout { } + protected static class CameraListenerMiddleWare extends CameraListener { + + private CameraListener mCameraListener; + + public CameraListenerMiddleWare(CameraListener cameraListener) { + this.mCameraListener = cameraListener; + } + + @Override + public void onCameraOpened() { + super.onCameraOpened(); + mCameraListener.onCameraOpened(); + } + + @Override + public void onCameraClosed() { + super.onCameraClosed(); + mCameraListener.onCameraClosed(); + } + + @Override + public void onPictureTaken(byte[] picture) { + super.onPictureTaken(picture); + mCameraListener.onPictureTaken(picture); + } + + @Override + public void onVideoTaken(File video) { + super.onVideoTaken(video); + mCameraListener.onCameraOpened(); + } + + } + }