Search in sources :

Example 66 with ReactMethod

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);
    }
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) Activity(android.app.Activity) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 67 with ReactMethod

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);
    }
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) Activity(android.app.Activity) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 68 with ReactMethod

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);
    }
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) Activity(android.app.Activity) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 69 with ReactMethod

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);
    }
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) Activity(android.app.Activity) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 70 with ReactMethod

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);
    }
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) Activity(android.app.Activity) ReactMethod(com.facebook.react.bridge.ReactMethod)

Aggregations

ReactMethod (com.facebook.react.bridge.ReactMethod)87 Activity (android.app.Activity)21 WritableMap (com.facebook.react.bridge.WritableMap)17 Intent (android.content.Intent)10 Bundle (android.os.Bundle)10 ReactApplicationContext (com.facebook.react.bridge.ReactApplicationContext)6 WritableArray (com.facebook.react.bridge.WritableArray)5 ArrayList (java.util.ArrayList)5 Camera (android.hardware.Camera)4 InterstitialAd (com.facebook.ads.InterstitialAd)4 ShareContent (com.facebook.share.model.ShareContent)4 LayoutNode (com.reactnativenavigation.options.LayoutNode)4 LoginManager (com.facebook.login.LoginManager)3 ReactActivity (com.facebook.react.ReactActivity)3 LatLng (com.google.android.gms.maps.model.LatLng)3 NotificationManager (android.app.NotificationManager)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2 RemoteException (android.os.RemoteException)2 NativeAdsManager (com.facebook.ads.NativeAdsManager)2 JSApplicationIllegalArgumentException (com.facebook.react.bridge.JSApplicationIllegalArgumentException)2