Java 类com.facebook.react.devsupport.interfaces.DevSupportManager 实例源码

项目:react-native-async-storage-dev-menu-item    文件:AsyncStorageDevMenuItemModule.java   
@ReactMethod
public void initialize() {
  ReactApplication application = (ReactApplication)getReactApplicationContext()
    .getCurrentActivity()
    .getApplication();

  DevSupportManager devSupportManager = application
    .getReactNativeHost()
    .getReactInstanceManager()
    .getDevSupportManager();

  devSupportManager.addCustomDevOption("Log AsyncStorage", new DevOptionHandler() {
      @Override
      public void onOptionSelected() {
        getReactApplicationContext()
          .getJSModule(RCTNativeAppEventEmitter.class)
          .emit("LogAsyncStorage", null);
      }
  });
}
项目:RNLearn_Project1    文件:Timing.java   
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 HashMap<>();
  mSendIdleEventsExecutorTokens = new HashSet<>();
  mIdleCallbackContextsToCall = new ArrayList<>();
}
项目:RNLearn_Project1    文件:ReactIntegrationTestCase.java   
/**
 * 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() {
          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);
  }
}
项目:RNLearn_Project1    文件:Timing.java   
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 HashMap<>();
  mSendIdleEventsExecutorTokens = new HashSet<>();
  mIdleCallbackContextsToCall = new ArrayList<>();
}
项目:RNLearn_Project1    文件:ReactIntegrationTestCase.java   
/**
 * 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() {
          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);
  }
}
项目:react-native-android-activity    文件:MainActivity.java   
/**
 * Demonstrates how to add a custom option to the dev menu.
 * https://stackoverflow.com/a/44882371/3968276
 */
@Override
protected void onCreate(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() {
            Toast.makeText(MainActivity.this, "Hello from custom dev option", Toast.LENGTH_SHORT).show();
        }
    });
}
项目:RNLearn_Project1    文件:DevSupportManagerFactory.java   
public static DevSupportManager create(
    Context applicationContext,
    ReactInstanceDevCommandsHandler reactInstanceCommandsHandler,
    @Nullable String packagerPathForJSBundleName,
    boolean enableOnCreate) {

  return create(
    applicationContext,
    reactInstanceCommandsHandler,
    packagerPathForJSBundleName,
    enableOnCreate,
    null);
}
项目:RNLearn_Project1    文件:DevSupportManagerFactory.java   
public static DevSupportManager create(
  Context applicationContext,
  ReactInstanceDevCommandsHandler reactInstanceCommandsHandler,
  @Nullable String packagerPathForJSBundleName,
  boolean enableOnCreate,
  @Nullable RedBoxHandler redBoxHandler) {
  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,
        ReactInstanceDevCommandsHandler.class,
        String.class,
        boolean.class,
        RedBoxHandler.class);
    return (DevSupportManager) constructor.newInstance(
      applicationContext,
      reactInstanceCommandsHandler,
      packagerPathForJSBundleName,
      true,
      redBoxHandler);
  } catch (Exception e) {
    throw new RuntimeException(
      "Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found" +
        " or could not be created",
      e);
  }
}
项目:RNLearn_Project1    文件:DevSupportManagerFactory.java   
public static DevSupportManager create(
    Context applicationContext,
    ReactInstanceDevCommandsHandler reactInstanceCommandsHandler,
    @Nullable String packagerPathForJSBundleName,
    boolean enableOnCreate) {

  return create(
    applicationContext,
    reactInstanceCommandsHandler,
    packagerPathForJSBundleName,
    enableOnCreate,
    null);
}
项目:RNLearn_Project1    文件:DevSupportManagerFactory.java   
public static DevSupportManager create(
  Context applicationContext,
  ReactInstanceDevCommandsHandler reactInstanceCommandsHandler,
  @Nullable String packagerPathForJSBundleName,
  boolean enableOnCreate,
  @Nullable RedBoxHandler redBoxHandler) {
  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,
        ReactInstanceDevCommandsHandler.class,
        String.class,
        boolean.class,
        RedBoxHandler.class);
    return (DevSupportManager) constructor.newInstance(
      applicationContext,
      reactInstanceCommandsHandler,
      packagerPathForJSBundleName,
      true,
      redBoxHandler);
  } catch (Exception e) {
    throw new RuntimeException(
      "Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found" +
        " or could not be created",
      e);
  }
}
项目:react-native-threads    文件:ReactContextBuilder.java   
public ReactContextBuilder setDevSupportManager(DevSupportManager devSupportManager) {
    this.devSupportManager = devSupportManager;
    return this;
}
项目:react-native-threads    文件:RNThreadModule.java   
private DevSupportManager getDevSupportManager() {
  return getReactInstanceManager().getDevSupportManager();
}
项目:RNLearn_Project1    文件:ExceptionsManagerModule.java   
public ExceptionsManagerModule(DevSupportManager devSupportManager) {
  mDevSupportManager = devSupportManager;
}
项目:RNLearn_Project1    文件:ReactInstanceManager.java   
public DevSupportManager getDevSupportManager() {
  return mDevSupportManager;
}
项目:RNLearn_Project1    文件:RedBoxDialog.java   
private OpenStackFrameTask(DevSupportManager devSupportManager) {
  mDevSupportManager = devSupportManager;
}
项目:RNLearn_Project1    文件:RedBoxDialog.java   
private CopyToHostClipBoardTask(DevSupportManager devSupportManager) {
  mDevSupportManager = devSupportManager;
}
项目:RNLearn_Project1    文件:ExceptionsManagerModule.java   
public ExceptionsManagerModule(DevSupportManager devSupportManager) {
  mDevSupportManager = devSupportManager;
}
项目:RNLearn_Project1    文件:ReactInstanceManager.java   
public DevSupportManager getDevSupportManager() {
  return mDevSupportManager;
}
项目:RNLearn_Project1    文件:RedBoxDialog.java   
private OpenStackFrameTask(DevSupportManager devSupportManager) {
  mDevSupportManager = devSupportManager;
}
项目:RNLearn_Project1    文件:RedBoxDialog.java   
private CopyToHostClipBoardTask(DevSupportManager devSupportManager) {
  mDevSupportManager = devSupportManager;
}