com.facebook.react.ReactApplication Java Examples
The following examples show how to use
com.facebook.react.ReactApplication.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RNCustomKeyboardKitModule.java From react-native-custom-keyboard-kit with MIT License | 6 votes |
private View createCustomKeyboardKit(Activity activity, int tag, String type) { RelativeLayout layout = new RelativeLayout(activity); rootView = new ReactRootView(this.getReactApplicationContext()); rootView.setBackgroundColor(Color.WHITE); Bundle bundle = new Bundle(); bundle.putInt("tag", tag); bundle.putString("type", type); rootView.startReactApplication( ((ReactApplication) activity.getApplication()).getReactNativeHost().getReactInstanceManager(), "CustomKeyboardKit", bundle); final float scale = activity.getResources().getDisplayMetrics().density; RelativeLayout.LayoutParams lParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Math.round(216*scale)); lParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layout.addView(rootView, lParams); // activity.addContentView(layout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return layout; }
Example #2
Source File: RestartModule.java From react-native-restart with MIT License | 6 votes |
private ReactInstanceManager resolveInstanceManager() throws NoSuchFieldException, IllegalAccessException { ReactInstanceManager instanceManager = getReactInstanceManager(); if (instanceManager != null) { return instanceManager; } final Activity currentActivity = getCurrentActivity(); if (currentActivity == null) { return null; } ReactApplication reactApplication = (ReactApplication) currentActivity.getApplication(); instanceManager = reactApplication.getReactNativeHost().getReactInstanceManager(); return instanceManager; }
Example #3
Source File: RNWorkersManager.java From react-native-workers with Apache License 2.0 | 5 votes |
public <T extends Application & ReactApplication> void init(final T reactApp, final RNWorker... workers) { mMainHost = reactApp.getReactNativeHost(); mRNWorkers = new ArrayList<>(); if (workers != null && workers.length > 0) { mRNWorkers.addAll(Arrays.asList(workers)); } mMainHost.getReactInstanceManager().addReactInstanceEventListener(mMainHostListener); reactApp.registerActivityLifecycleCallbacks(mLifecycleCallbacks); }
Example #4
Source File: RNWorker.java From react-native-workers with Apache License 2.0 | 5 votes |
public static <T extends Application & ReactApplication> RNWorker createDefault( final T application, final boolean developerSupport) { return new Builder(application, developerSupport) .entryPoint(DEFAULT_JS_ENTRY_POINT) .bundleAsset(DEFAULT_JS_BUNDLE_ASSET) .port(DEFAULT_WORKER_PORT) .build(); }
Example #5
Source File: RNDevMenuModule.java From react-native-dev-menu with MIT License | 5 votes |
@ReactMethod public void addItem(final String name, Promise promise) { if (mNames == null) { mNames = new ArrayList<>(); } if (mNames.contains(name)) { promise.resolve(null); } try { ReactApplication application = (ReactApplication)getReactApplicationContext() .getCurrentActivity() .getApplication(); DevSupportManager manager = application .getReactNativeHost() .getReactInstanceManager() .getDevSupportManager(); manager.addCustomDevOption(name, new DevOptionHandler() { @Override public void onOptionSelected() { getReactApplicationContext().getJSModule(RCTDeviceEventEmitter.class) .emit("customDevOptionTap", name); } }); mNames.add(name); promise.resolve(null); } catch (Exception e) { promise.reject(e); } }
Example #6
Source File: ReactNativeEventStarter.java From react-native-background-job with MIT License | 5 votes |
@Nullable @Override protected HeadlessJsTaskConfig getTaskConfig(Intent intent) { Log.d(LOG_TAG, "getTaskConfig() called with: intent = [" + intent + "]"); Bundle extras = intent.getExtras(); boolean allowExecutionInForeground = extras.getBoolean("allowExecutionInForeground", false); long timeout = extras.getLong("timeout", 2000); // For task with quick execution period additional check is required ReactNativeHost reactNativeHost = ((ReactApplication) getApplicationContext()).getReactNativeHost(); boolean appInForeground = Utils.isReactNativeAppInForeground(reactNativeHost); if (appInForeground && !allowExecutionInForeground) { return null; } return new HeadlessJsTaskConfig(intent.getStringExtra("jobKey"), Arguments.fromBundle(extras), timeout, allowExecutionInForeground); }
Example #7
Source File: ReactPreLoader.java From react-native-preloader with Apache License 2.0 | 5 votes |
/** * Pre-load {@link ReactRootView} to local {@link Map}, you may want to * load it in previous activity. */ public static void init(Activity activity, ReactInfo reactInfo) { if (CACHE_VIEW_MAP.get(reactInfo.getMainComponentName()) != null) { return; } ReactRootView rootView = new ReactRootView(new MutableContextWrapper(activity)); rootView.startReactApplication( ((ReactApplication) activity.getApplication()).getReactNativeHost().getReactInstanceManager(), reactInfo.getMainComponentName(), reactInfo.getLaunchOptions()); CACHE_VIEW_MAP.put(reactInfo.getMainComponentName(), rootView); }
Example #8
Source File: RCTUpdate.java From react-native-update with MIT License | 5 votes |
private ReactInstanceManager resolveInstanceManager() throws NoSuchFieldException, IllegalAccessException { ReactInstanceManager instanceManager; final Activity currentActivity = getCurrentActivity(); if (currentActivity == null) { return null; } ReactApplication reactApplication = (ReactApplication) currentActivity.getApplication(); instanceManager = reactApplication.getReactNativeHost().getReactInstanceManager(); return instanceManager; }
Example #9
Source File: FloatingVideoWidgetShowService.java From rn-floating-video-widget with MIT License | 4 votes |
protected ReactNativeHost getReactNativeHost() { return ((ReactApplication) getApplication()).getReactNativeHost(); }
Example #10
Source File: JsLoaderUtil.java From MetroExample with Apache License 2.0 | 4 votes |
public static ReactInstanceManager getReactIM(Application application) { return ((ReactApplication) application).getReactNativeHost().getReactInstanceManager(); }
Example #11
Source File: RNWorkersManager.java From react-native-workers with Apache License 2.0 | 4 votes |
public <T extends Application & ReactApplication> void init( final T reactApp, boolean developerSupport) { init(reactApp, RNWorker.createDefault(reactApp, developerSupport)); }
Example #12
Source File: WorkerModule.java From react-native-workers with BSD 2-Clause "Simplified" License | 4 votes |
private ReactInstanceManager getReactInstanceManager() { ReactApplication reactApplication = (ReactApplication)getCurrentActivity().getApplication(); return reactApplication.getReactNativeHost().getReactInstanceManager(); }
Example #13
Source File: ReactNativeEventStarter.java From react-native-background-job with MIT License | 4 votes |
public ReactNativeEventStarter(@NonNull Context context) { this.context = context; reactNativeHost = ((ReactApplication) context.getApplicationContext()).getReactNativeHost(); }
Example #14
Source File: ReactFragment.java From react-native-android-fragment with Apache License 2.0 | 2 votes |
/** * Get the {@link ReactNativeHost} used by this app. By default, assumes * {@link Activity#getApplication()} is an instance of {@link ReactApplication} and calls * {@link ReactApplication#getReactNativeHost()}. Override this method if your application class * does not implement {@code ReactApplication} or you simply have a different mechanism for * storing a {@code ReactNativeHost}, e.g. as a static field somewhere. */ protected ReactNativeHost getReactNativeHost() { return ((ReactApplication) getActivity().getApplication()).getReactNativeHost(); }
Example #15
Source File: MrReactActivity.java From react-native-preloader with Apache License 2.0 | 2 votes |
/** * Get the {@link ReactNativeHost} used by this app. By default, assumes {@link #getApplication()} * is an instance of {@link ReactApplication} and calls * {@link ReactApplication#getReactNativeHost()}. Override this method if your application class * does not implement {@code ReactApplication} or you simply have a different mechanism for * storing a {@code ReactNativeHost}, e.g. as a static field somewhere. */ protected ReactNativeHost getReactNativeHost() { return ((ReactApplication) getApplication()).getReactNativeHost(); }