com.facebook.react.devsupport.interfaces.DevSupportManager Java Examples
The following examples show how to use
com.facebook.react.devsupport.interfaces.DevSupportManager.
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: Timing.java From react-native-GPay with MIT License | 7 votes |
public Timing(ReactApplicationContext reactContext, DevSupportManager devSupportManager) { super(reactContext); mDevSupportManager = devSupportManager; // We store timers sorted by finish time. mTimers = new PriorityQueue<Timer>( 11, // Default capacity: for some reason they don't expose a (Comparator) constructor new Comparator<Timer>() { @Override public int compare(Timer lhs, Timer rhs) { long diff = lhs.mTargetTime - rhs.mTargetTime; if (diff == 0) { return 0; } else if (diff < 0) { return -1; } else { return 1; } } }); mTimerIdsToTimers = new SparseArray<>(); mReactChoreographer = ReactChoreographer.getInstance(); }
Example #2
Source File: MainActivity.java From react-native-android-activity with MIT License | 7 votes |
/** * Demonstrates how to add a custom option to the dev menu. * https://stackoverflow.com/a/44882371/3968276 * This only works from the debug build with dev options enabled. */ @Override @CallSuper protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); MainApplication application = (MainApplication) getApplication(); ReactNativeHost reactNativeHost = application.getReactNativeHost(); ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager(); DevSupportManager devSupportManager = reactInstanceManager.getDevSupportManager(); devSupportManager.addCustomDevOption("Custom dev option", new DevOptionHandler() { @Override public void onOptionSelected() { if (NotificationManagerCompat.from(MainActivity.this).areNotificationsEnabled()) { Toast.makeText(MainActivity.this, CUSTOM_DEV_OPTION_MESSAGE, Toast.LENGTH_LONG).show(); } else { AlertDialog dialog = new AlertDialog.Builder(MainActivity.this).create(); dialog.setTitle("Dev option"); dialog.setMessage(CUSTOM_DEV_OPTION_MESSAGE); dialog.show(); } } }); }
Example #3
Source File: DevSupportManagerFactory.java From react-native-GPay with MIT License | 6 votes |
public static DevSupportManager create( Context applicationContext, ReactInstanceManagerDevHelper reactInstanceManagerHelper, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, int minNumShakes) { return create( applicationContext, reactInstanceManagerHelper, packagerPathForJSBundleName, enableOnCreate, null, null, minNumShakes, null); }
Example #4
Source File: ReactIntegrationTestCase.java From react-native-GPay with MIT License | 6 votes |
/** * Timing module needs to be created on the main thread so that it gets the correct Choreographer. */ protected Timing createTimingModule() { final SimpleSettableFuture<Timing> simpleSettableFuture = new SimpleSettableFuture<Timing>(); UiThreadUtil.runOnUiThread( new Runnable() { @Override public void run() { ReactChoreographer.initialize(); Timing timing = new Timing(getContext(), mock(DevSupportManager.class)); simpleSettableFuture.set(timing); } }); try { return simpleSettableFuture.get(5000, TimeUnit.MILLISECONDS); } catch (Exception e) { throw new RuntimeException(e); } }
Example #5
Source File: RedBoxDialog.java From react-native-GPay with MIT License | 5 votes |
private OpenStackFrameTask(DevSupportManager devSupportManager) { mDevSupportManager = devSupportManager; }
Example #6
Source File: RedBoxDialog.java From react-native-GPay with MIT License | 5 votes |
private CopyToHostClipBoardTask(DevSupportManager devSupportManager) { mDevSupportManager = devSupportManager; }
Example #7
Source File: ReactContextBuilder.java From react-native-threads with MIT License | 5 votes |
public ReactContextBuilder setDevSupportManager(DevSupportManager devSupportManager) { this.devSupportManager = devSupportManager; return this; }
Example #8
Source File: RNThreadModule.java From react-native-threads with MIT License | 5 votes |
private DevSupportManager getDevSupportManager() { return getReactInstanceManager().getDevSupportManager(); }
Example #9
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 #10
Source File: JsDevReloadHandler.java From react-native-navigation with MIT License | 5 votes |
JsDevReloadHandler(DevSupportManager devSupportManager) { this.devSupportManager = devSupportManager; }
Example #11
Source File: ExceptionsManagerModule.java From react-native-GPay with MIT License | 4 votes |
public ExceptionsManagerModule(DevSupportManager devSupportManager) { mDevSupportManager = devSupportManager; }
Example #12
Source File: ReactInstanceManager.java From react-native-GPay with MIT License | 4 votes |
public DevSupportManager getDevSupportManager() { return mDevSupportManager; }
Example #13
Source File: DevSupportManagerFactory.java From react-native-GPay with MIT License | 4 votes |
public static DevSupportManager create( Context applicationContext, ReactInstanceManagerDevHelper reactInstanceManagerHelper, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler, @Nullable DevBundleDownloadListener devBundleDownloadListener, int minNumShakes, @Nullable Map<String, RequestHandler> customPackagerCommandHandlers) { if (!enableOnCreate) { return new DisabledDevSupportManager(); } try { // ProGuard is surprisingly smart in this case and will keep a class if it detects a call to // Class.forName() with a static string. So instead we generate a quasi-dynamic string to // confuse it. String className = new StringBuilder(DEVSUPPORT_IMPL_PACKAGE) .append(".") .append(DEVSUPPORT_IMPL_CLASS) .toString(); Class<?> devSupportManagerClass = Class.forName(className); Constructor constructor = devSupportManagerClass.getConstructor( Context.class, ReactInstanceManagerDevHelper.class, String.class, boolean.class, RedBoxHandler.class, DevBundleDownloadListener.class, int.class, Map.class); return (DevSupportManager) constructor.newInstance( applicationContext, reactInstanceManagerHelper, packagerPathForJSBundleName, true, redBoxHandler, devBundleDownloadListener, minNumShakes, customPackagerCommandHandlers); } catch (Exception e) { throw new RuntimeException( "Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found" + " or could not be created", e); } }