Search in sources :

Example 1 with ReactInstanceManager

use of com.facebook.react.ReactInstanceManager in project react-native-navigation by wix.

the class JsDevReloadHandler method onKeyUp.

boolean onKeyUp(View currentFocus, int keyCode) {
    ReactInstanceManager reactInstanceManager = getReactInstanceManager();
    if (reactInstanceManager != null && reactInstanceManager.getDevSupportManager().getDevSupportEnabled()) {
        if (keyCode == KeyEvent.KEYCODE_MENU) {
            reactInstanceManager.showDevOptionsDialog();
            return true;
        }
        if (keyCode == KeyEvent.KEYCODE_R && !(currentFocus instanceof EditText)) {
            // Enable double-tap-R-to-reload
            if (shouldRefreshOnRR) {
                reload();
                return true;
            } else {
                shouldRefreshOnRR = true;
                NavigationApplication.instance.runOnMainThread(new Runnable() {

                    @Override
                    public void run() {
                        shouldRefreshOnRR = false;
                    }
                }, 500);
            }
        }
    }
    return false;
}
Also used : EditText(android.widget.EditText) ReactInstanceManager(com.facebook.react.ReactInstanceManager)

Example 2 with ReactInstanceManager

use of com.facebook.react.ReactInstanceManager in project react-native-fbsdk by facebook.

the class ReactNativeFlipper method initializeFlipper.

public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
    if (FlipperUtils.shouldEnableFlipper(context)) {
        final FlipperClient client = AndroidFlipperClient.getInstance(context);
        client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
        client.addPlugin(new ReactFlipperPlugin());
        client.addPlugin(new DatabasesFlipperPlugin(context));
        client.addPlugin(new SharedPreferencesFlipperPlugin(context));
        client.addPlugin(CrashReporterPlugin.getInstance());
        NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
        NetworkingModule.setCustomClientBuilder(new NetworkingModule.CustomClientBuilder() {

            @Override
            public void apply(OkHttpClient.Builder builder) {
                builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
            }
        });
        client.addPlugin(networkFlipperPlugin);
        client.start();
        // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
        // Hence we run if after all native modules have been initialized
        ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
        if (reactContext == null) {
            reactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {

                @Override
                public void onReactContextInitialized(ReactContext reactContext) {
                    reactInstanceManager.removeReactInstanceEventListener(this);
                    reactContext.runOnNativeModulesQueueThread(new Runnable() {

                        @Override
                        public void run() {
                            client.addPlugin(new FrescoFlipperPlugin());
                        }
                    });
                }
            });
        } else {
            client.addPlugin(new FrescoFlipperPlugin());
        }
    }
}
Also used : FlipperOkhttpInterceptor(com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor) AndroidFlipperClient(com.facebook.flipper.android.AndroidFlipperClient) FlipperClient(com.facebook.flipper.core.FlipperClient) OkHttpClient(okhttp3.OkHttpClient) ReactInstanceManager(com.facebook.react.ReactInstanceManager) InspectorFlipperPlugin(com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin) ReactFlipperPlugin(com.facebook.flipper.plugins.react.ReactFlipperPlugin) DatabasesFlipperPlugin(com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin) ReactContext(com.facebook.react.bridge.ReactContext) FrescoFlipperPlugin(com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin) NetworkFlipperPlugin(com.facebook.flipper.plugins.network.NetworkFlipperPlugin) SharedPreferencesFlipperPlugin(com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin) NetworkingModule(com.facebook.react.modules.network.NetworkingModule)

Example 3 with ReactInstanceManager

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

the class ReactNativeFlipper method initializeFlipper.

public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
    if (FlipperUtils.shouldEnableFlipper(context)) {
        final FlipperClient client = AndroidFlipperClient.getInstance(context);
        client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
        client.addPlugin(new ReactFlipperPlugin());
        client.addPlugin(new DatabasesFlipperPlugin(context));
        client.addPlugin(new SharedPreferencesFlipperPlugin(context));
        client.addPlugin(CrashReporterPlugin.getInstance());
        NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
        NetworkingModule.setCustomClientBuilder(new NetworkingModule.CustomClientBuilder() {

            @Override
            public void apply(OkHttpClient.Builder builder) {
                builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
            }
        });
        client.addPlugin(networkFlipperPlugin);
        client.start();
        // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
        // Hence we run if after all native modules have been initialized
        ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
        if (reactContext == null) {
            reactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {

                @Override
                public void onReactContextInitialized(ReactContext reactContext) {
                    reactInstanceManager.removeReactInstanceEventListener(this);
                    reactContext.runOnNativeModulesQueueThread(new Runnable() {

                        @Override
                        public void run() {
                            client.addPlugin(new FrescoFlipperPlugin());
                        }
                    });
                }
            });
        } else {
            client.addPlugin(new FrescoFlipperPlugin());
        }
    }
}
Also used : FlipperOkhttpInterceptor(com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor) AndroidFlipperClient(com.facebook.flipper.android.AndroidFlipperClient) FlipperClient(com.facebook.flipper.core.FlipperClient) OkHttpClient(okhttp3.OkHttpClient) ReactInstanceManager(com.facebook.react.ReactInstanceManager) InspectorFlipperPlugin(com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin) ReactFlipperPlugin(com.facebook.flipper.plugins.react.ReactFlipperPlugin) DatabasesFlipperPlugin(com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin) ReactContext(com.facebook.react.bridge.ReactContext) FrescoFlipperPlugin(com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin) NetworkFlipperPlugin(com.facebook.flipper.plugins.network.NetworkFlipperPlugin) SharedPreferencesFlipperPlugin(com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin) NetworkingModule(com.facebook.react.modules.network.NetworkingModule)

Example 4 with ReactInstanceManager

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

the class ReactNativeFlipper method initializeFlipper.

public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
    if (FlipperUtils.shouldEnableFlipper(context)) {
        final FlipperClient client = AndroidFlipperClient.getInstance(context);
        client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
        client.addPlugin(new ReactFlipperPlugin());
        client.addPlugin(new DatabasesFlipperPlugin(context));
        client.addPlugin(new SharedPreferencesFlipperPlugin(context));
        client.addPlugin(CrashReporterPlugin.getInstance());
        NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
        NetworkingModule.setCustomClientBuilder(new NetworkingModule.CustomClientBuilder() {

            @Override
            public void apply(OkHttpClient.Builder builder) {
                builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
            }
        });
        client.addPlugin(networkFlipperPlugin);
        client.start();
        // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
        // Hence we run if after all native modules have been initialized
        ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
        if (reactContext == null) {
            reactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {

                @Override
                public void onReactContextInitialized(ReactContext reactContext) {
                    reactInstanceManager.removeReactInstanceEventListener(this);
                    reactContext.runOnNativeModulesQueueThread(new Runnable() {

                        @Override
                        public void run() {
                            client.addPlugin(new FrescoFlipperPlugin());
                        }
                    });
                }
            });
        } else {
            client.addPlugin(new FrescoFlipperPlugin());
        }
    }
}
Also used : FlipperOkhttpInterceptor(com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor) AndroidFlipperClient(com.facebook.flipper.android.AndroidFlipperClient) FlipperClient(com.facebook.flipper.core.FlipperClient) OkHttpClient(okhttp3.OkHttpClient) ReactInstanceManager(com.facebook.react.ReactInstanceManager) InspectorFlipperPlugin(com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin) ReactFlipperPlugin(com.facebook.flipper.plugins.react.ReactFlipperPlugin) DatabasesFlipperPlugin(com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin) ReactContext(com.facebook.react.bridge.ReactContext) FrescoFlipperPlugin(com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin) NetworkFlipperPlugin(com.facebook.flipper.plugins.network.NetworkFlipperPlugin) SharedPreferencesFlipperPlugin(com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin) NetworkingModule(com.facebook.react.modules.network.NetworkingModule)

Example 5 with ReactInstanceManager

use of com.facebook.react.ReactInstanceManager in project react-native-navigation by wix.

the class ExternalComponentViewControllerTest method beforeEach.

@Override
public void beforeEach() {
    componentCreator = spy(new FragmentCreatorMock());
    activity = newActivity();
    ec = createExternalComponent();
    reactInstanceManager = Mockito.mock(ReactInstanceManager.class);
    emitter = Mockito.mock(EventEmitter.class);
    childRegistry = new ChildControllersRegistry();
    uut = spy(new ExternalComponentViewController(activity, childRegistry, "fragmentId", new Presenter(activity, Options.EMPTY), ec, componentCreator, reactInstanceManager, emitter, new ExternalComponentPresenter(), new Options()));
}
Also used : Options(com.reactnativenavigation.options.Options) ReactInstanceManager(com.facebook.react.ReactInstanceManager) EventEmitter(com.reactnativenavigation.react.events.EventEmitter) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)

Aggregations

ReactInstanceManager (com.facebook.react.ReactInstanceManager)11 ReactContext (com.facebook.react.bridge.ReactContext)8 Handler (android.os.Handler)4 AndroidFlipperClient (com.facebook.flipper.android.AndroidFlipperClient)4 FlipperClient (com.facebook.flipper.core.FlipperClient)4 DatabasesFlipperPlugin (com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin)4 FrescoFlipperPlugin (com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin)4 InspectorFlipperPlugin (com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin)4 FlipperOkhttpInterceptor (com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor)4 NetworkFlipperPlugin (com.facebook.flipper.plugins.network.NetworkFlipperPlugin)4 ReactFlipperPlugin (com.facebook.flipper.plugins.react.ReactFlipperPlugin)4 SharedPreferencesFlipperPlugin (com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin)4 NetworkingModule (com.facebook.react.modules.network.NetworkingModule)4 OkHttpClient (okhttp3.OkHttpClient)4 Intent (android.content.Intent)3 ReactApplication (com.facebook.react.ReactApplication)3 ReactApplicationContext (com.facebook.react.bridge.ReactApplicationContext)2 EventEmitter (com.reactnativenavigation.react.events.EventEmitter)2 ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)2 Bundle (android.os.Bundle)1