setup cameralistener middleware

pull/1/head
Dylan McIntyre 8 years ago
parent 6bf8576b16
commit f25e5bc826
  1. 2
      build.gradle
  2. 4
      camerakit/src/main/java/com/flurgle/camerakit/CameraListener.java
  3. 43
      camerakit/src/main/java/com/flurgle/camerakit/CameraView.java

@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { 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 // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

@ -12,10 +12,6 @@ public abstract class CameraListener {
} }
public void onPictureTaken(File picture) {
}
public void onPictureTaken(byte[] picture) { public void onPictureTaken(byte[] picture) {
} }

@ -15,6 +15,7 @@ import android.util.AttributeSet;
import android.view.Display; import android.view.Display;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import java.io.File;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
@ -206,9 +207,13 @@ public class CameraView extends FrameLayout {
this.mPictureMode = pictureMode; this.mPictureMode = pictureMode;
} }
public void setCropOutput(boolean cropOutput) {
this.mCropOutput = cropOutput;
}
public void setCameraListener(CameraListener cameraListener) { public void setCameraListener(CameraListener cameraListener) {
this.mCameraListener = cameraListener; this.mCameraListener = new CameraListenerMiddleWare(cameraListener);
mCameraImpl.setCameraListener(cameraListener); mCameraImpl.setCameraListener(mCameraListener);
} }
public void capturePicture() { 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();
}
}
} }

Loading…
Cancel
Save