Java Code Examples for com.facebook.react.bridge.ReactContextBaseJavaModule

The following are top voted examples for showing how to use com.facebook.react.bridge.ReactContextBaseJavaModule. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: RxRNBridge   File: RxRNBridge.java   View source code 6 votes vote down vote up
@NonNull
public static NativeModule newInstance(Class<? extends ReactContextBaseJavaModule> reactModuleClass, ReactApplicationContext reactContext)
        throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
    String clsName = reactModuleClass.getName();
    String injectClsName = clsName + GEN_CLASS_SUFFIX;
    Class <? extends ReactContextBaseJavaModule> injectCls = null;
    try {
        injectCls = Class.forName(injectClsName).asSubclass(ReactContextBaseJavaModule.class);
    } catch (ClassNotFoundException e) {
        Log.e(TAG, "Unable to find injectClass - " + injectClsName);
    }

    return (NativeModule) (injectCls != null
            ? injectCls.getDeclaredConstructor(ReactApplicationContext.class).newInstance(reactContext)
            : reactModuleClass.getDeclaredConstructor(ReactApplicationContext.class).newInstance(reactContext));
}