Search in sources :

Example 11 with UIBlock

use of com.facebook.react.uimanager.UIBlock in project react-native-camera by react-native-community.

the class CameraModule method resumeRecording.

@ReactMethod
public void resumeRecording(final int viewTag) {
    final ReactApplicationContext context = getReactApplicationContext();
    UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {

        @Override
        public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
            final RNCameraView cameraView;
            try {
                cameraView = (RNCameraView) nativeViewHierarchyManager.resolveView(viewTag);
                if (cameraView.isCameraOpened()) {
                    cameraView.resumeRecording();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
Also used : UIBlock(com.facebook.react.uimanager.UIBlock) UIManagerModule(com.facebook.react.uimanager.UIManagerModule) NativeViewHierarchyManager(com.facebook.react.uimanager.NativeViewHierarchyManager)

Example 12 with UIBlock

use of com.facebook.react.uimanager.UIBlock in project react-native-camera by react-native-community.

the class CameraModule method record.

@ReactMethod
public void record(final ReadableMap options, final int viewTag, final Promise promise) {
    final ReactApplicationContext context = getReactApplicationContext();
    final File cacheDirectory = mScopedContext.getCacheDirectory();
    UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {

        @Override
        public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
            final RNCameraView cameraView;
            try {
                cameraView = (RNCameraView) nativeViewHierarchyManager.resolveView(viewTag);
                if (cameraView.isCameraOpened()) {
                    cameraView.record(options, promise, cacheDirectory);
                } else {
                    promise.reject("E_CAMERA_UNAVAILABLE", "Camera is not running");
                }
            } catch (Exception e) {
                promise.reject("E_CAPTURE_FAILED", e.getMessage());
            }
        }
    });
}
Also used : UIBlock(com.facebook.react.uimanager.UIBlock) UIManagerModule(com.facebook.react.uimanager.UIManagerModule) File(java.io.File) NativeViewHierarchyManager(com.facebook.react.uimanager.NativeViewHierarchyManager)

Example 13 with UIBlock

use of com.facebook.react.uimanager.UIBlock in project react-native-camera by lwansbrough.

the class CameraModule method stopRecording.

@ReactMethod
public void stopRecording(final int viewTag) {
    final ReactApplicationContext context = getReactApplicationContext();
    UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {

        @Override
        public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
            final RNCameraView cameraView;
            try {
                cameraView = (RNCameraView) nativeViewHierarchyManager.resolveView(viewTag);
                if (cameraView.isCameraOpened()) {
                    cameraView.stopRecording();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
Also used : UIBlock(com.facebook.react.uimanager.UIBlock) UIManagerModule(com.facebook.react.uimanager.UIManagerModule) NativeViewHierarchyManager(com.facebook.react.uimanager.NativeViewHierarchyManager)

Example 14 with UIBlock

use of com.facebook.react.uimanager.UIBlock in project react-native-camera by lwansbrough.

the class CameraModule method record.

@ReactMethod
public void record(final ReadableMap options, final int viewTag, final Promise promise) {
    final ReactApplicationContext context = getReactApplicationContext();
    final File cacheDirectory = mScopedContext.getCacheDirectory();
    UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {

        @Override
        public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
            final RNCameraView cameraView;
            try {
                cameraView = (RNCameraView) nativeViewHierarchyManager.resolveView(viewTag);
                if (cameraView.isCameraOpened()) {
                    cameraView.record(options, promise, cacheDirectory);
                } else {
                    promise.reject("E_CAMERA_UNAVAILABLE", "Camera is not running");
                }
            } catch (Exception e) {
                promise.reject("E_CAPTURE_FAILED", e.getMessage());
            }
        }
    });
}
Also used : UIBlock(com.facebook.react.uimanager.UIBlock) UIManagerModule(com.facebook.react.uimanager.UIManagerModule) File(java.io.File) NativeViewHierarchyManager(com.facebook.react.uimanager.NativeViewHierarchyManager)

Example 15 with UIBlock

use of com.facebook.react.uimanager.UIBlock in project react-native-camera by lwansbrough.

the class CameraModule method resumeRecording.

@ReactMethod
public void resumeRecording(final int viewTag) {
    final ReactApplicationContext context = getReactApplicationContext();
    UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {

        @Override
        public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
            final RNCameraView cameraView;
            try {
                cameraView = (RNCameraView) nativeViewHierarchyManager.resolveView(viewTag);
                if (cameraView.isCameraOpened()) {
                    cameraView.resumeRecording();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
Also used : UIBlock(com.facebook.react.uimanager.UIBlock) UIManagerModule(com.facebook.react.uimanager.UIManagerModule) NativeViewHierarchyManager(com.facebook.react.uimanager.NativeViewHierarchyManager)

Aggregations

NativeViewHierarchyManager (com.facebook.react.uimanager.NativeViewHierarchyManager)23 UIBlock (com.facebook.react.uimanager.UIBlock)23 UIManagerModule (com.facebook.react.uimanager.UIManagerModule)23 File (java.io.File)4 ArrayList (java.util.ArrayList)4 SortedSet (java.util.SortedSet)4 AspectRatio (com.google.android.cameraview.AspectRatio)2 Size (com.google.android.cameraview.Size)2 List (java.util.List)2 Properties (java.util.Properties)2 Set (java.util.Set)2 View (android.view.View)1 ReactRootView (com.facebook.react.ReactRootView)1 JSApplicationIllegalArgumentException (com.facebook.react.bridge.JSApplicationIllegalArgumentException)1