use of com.facebook.react.uimanager.UIBlock in project react-native-camera by react-native-community.
the class CameraModule method pausePreview.
@ReactMethod
public void pausePreview(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.pausePreview();
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
use of com.facebook.react.uimanager.UIBlock in project react-native-camera by react-native-community.
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();
}
}
});
}
use of com.facebook.react.uimanager.UIBlock in project react-native-camera by react-native-community.
the class CameraModule method getCameraIds.
@ReactMethod
public void getCameraIds(final int viewTag, final Promise promise) {
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);
WritableArray result = Arguments.createArray();
List<Properties> ids = cameraView.getCameraIds();
for (Properties p : ids) {
WritableMap m = new WritableNativeMap();
m.putString("id", p.getProperty("id"));
m.putInt("type", Integer.valueOf(p.getProperty("type")));
result.pushMap(m);
}
promise.resolve(result);
} catch (Exception e) {
e.printStackTrace();
promise.reject("E_CAMERA_FAILED", e.getMessage());
}
}
});
}
Aggregations