Skip to content

Commit

Permalink
Make safer calls on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrevik committed Aug 29, 2017
1 parent 1bcf857 commit 4e04e34
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -660,13 +660,23 @@ public void stopCapture(final Promise promise) {

@ReactMethod
public void stopPreview(ReadableMap options) {
Camera camera = RCTCamera.getInstance().acquireCameraInstance(options.getInt("type"));
RCTCamera instance = RCTCamera.getInstance();
if (instance == null) return;

Camera camera = instance.acquireCameraInstance(options.getInt("type"));
if (camera == null) return;

camera.stopPreview();
}

@ReactMethod
public void startPreview(ReadableMap options) {
Camera camera = RCTCamera.getInstance().acquireCameraInstance(options.getInt("type"));
RCTCamera instance = RCTCamera.getInstance();
if (instance == null) return;

Camera camera = instance.acquireCameraInstance(options.getInt("type"));
if (camera == null) return;

camera.startPreview();
}

Expand Down

0 comments on commit 4e04e34

Please sign in to comment.