use of com.facebook.react.bridge.ReactMethod in project react-native-orientation-locker by wonday.
the class OrientationModule method unlockAllOrientations.
@ReactMethod
public void unlockAllOrientations() {
final Activity activity = getCurrentActivity();
if (activity == null)
return;
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
isLocked = false;
// force send an UI orientation event when unlock
lastOrientationValue = lastDeviceOrientationValue;
WritableMap params = Arguments.createMap();
params.putString("orientation", lastOrientationValue);
if (ctx.hasActiveCatalystInstance()) {
ctx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("orientationDidChange", params);
}
// send a unlocked event
WritableMap lockParams = Arguments.createMap();
lockParams.putString("orientation", "UNKNOWN");
if (ctx.hasActiveCatalystInstance()) {
ctx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("lockDidChange", lockParams);
}
}
use of com.facebook.react.bridge.ReactMethod in project react-native-orientation-locker by wonday.
the class OrientationModule method lockToPortrait.
@ReactMethod
public void lockToPortrait() {
final Activity activity = getCurrentActivity();
if (activity == null)
return;
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
isLocked = true;
// force send an UI orientation event
lastOrientationValue = "PORTRAIT";
WritableMap params = Arguments.createMap();
params.putString("orientation", lastOrientationValue);
if (ctx.hasActiveCatalystInstance()) {
ctx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("orientationDidChange", params);
}
// send a locked event
WritableMap lockParams = Arguments.createMap();
lockParams.putString("orientation", lastOrientationValue);
if (ctx.hasActiveCatalystInstance()) {
ctx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("lockDidChange", lockParams);
}
}
use of com.facebook.react.bridge.ReactMethod in project react-native-orientation-locker by wonday.
the class OrientationModule method lockToLandscape.
@ReactMethod
public void lockToLandscape() {
final Activity activity = getCurrentActivity();
if (activity == null)
return;
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
isLocked = true;
// force send an UI orientation event
lastOrientationValue = "LANDSCAPE-LEFT";
WritableMap params = Arguments.createMap();
params.putString("orientation", lastOrientationValue);
if (ctx.hasActiveCatalystInstance()) {
ctx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("orientationDidChange", params);
}
// send a locked event
WritableMap lockParams = Arguments.createMap();
lockParams.putString("orientation", lastOrientationValue);
if (ctx.hasActiveCatalystInstance()) {
ctx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("lockDidChange", lockParams);
}
}
use of com.facebook.react.bridge.ReactMethod in project react-native-orientation-locker by wonday.
the class OrientationModule method lockToLandscapeLeft.
@ReactMethod
public void lockToLandscapeLeft() {
final Activity activity = getCurrentActivity();
if (activity == null)
return;
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
isLocked = true;
// force send an UI orientation event
lastOrientationValue = "LANDSCAPE-LEFT";
WritableMap params = Arguments.createMap();
params.putString("orientation", lastOrientationValue);
if (ctx.hasActiveCatalystInstance()) {
ctx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("orientationDidChange", params);
}
// send a locked event
WritableMap lockParams = Arguments.createMap();
lockParams.putString("orientation", lastOrientationValue);
if (ctx.hasActiveCatalystInstance()) {
ctx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("lockDidChange", lockParams);
}
}
use of com.facebook.react.bridge.ReactMethod in project react-native-orientation-locker by wonday.
the class OrientationModule method lockToLandscapeRight.
@ReactMethod
public void lockToLandscapeRight() {
final Activity activity = getCurrentActivity();
if (activity == null)
return;
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
isLocked = true;
// force send an UI orientation event
lastOrientationValue = "LANDSCAPE-RIGHT";
WritableMap params = Arguments.createMap();
params.putString("orientation", lastOrientationValue);
if (ctx.hasActiveCatalystInstance()) {
ctx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("orientationDidChange", params);
}
// send a locked event
WritableMap lockParams = Arguments.createMap();
lockParams.putString("orientation", lastOrientationValue);
if (ctx.hasActiveCatalystInstance()) {
ctx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("lockDidChange", lockParams);
}
}
Aggregations