MCPcopy Create free account
hub / github.com/Glamdring/EasyCamera / DefaultEasyCamera

Class DefaultEasyCamera

src/main/java/com/easycamera/DefaultEasyCamera.java:10–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8import java.io.IOException;
9
10public class DefaultEasyCamera implements EasyCamera {
11
12 private Camera camera;
13
14 public static final EasyCamera open() {
15 return new DefaultEasyCamera(Camera.open());
16 }
17
18 public static final EasyCamera open(int id) {
19 return new DefaultEasyCamera(Camera.open(id));
20 }
21 private DefaultEasyCamera(Camera camera) {
22 this.camera = camera;
23 }
24
25
26 @Override
27 public CameraActions startPreview(SurfaceHolder holder) throws IOException {
28 if (holder == null) {
29 throw new NullPointerException("You cannot start preview without a preview surface");
30 }
31 camera.setPreviewDisplay(holder);
32 camera.startPreview();
33 return new DefaultCameraActions(this);
34 }
35
36 @Override
37 public CameraActions startPreview(SurfaceTexture texture) throws IOException {
38 if (texture == null) {
39 throw new NullPointerException("You cannot start preview without a preview texture");
40 }
41 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
42 camera.setPreviewTexture(texture);
43 } else {
44 throw new IllegalStateException("Your Android version does not support this method.");
45 }
46 camera.startPreview();
47 return new DefaultCameraActions(this);
48 }
49
50 @Override
51 public void close() {
52 camera.release();
53 }
54
55 @Override
56 public void unlock() {
57 camera.unlock();
58 }
59
60 @Override
61 public void lock() {
62 camera.lock();
63 }
64
65 @Override
66 public void reconnect() throws IOException {
67 camera.reconnect();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected