当前位置: 首页>>代码示例>>Java>>正文


Java ReactBuildConfig类代码示例

本文整理汇总了Java中com.facebook.react.common.build.ReactBuildConfig的典型用法代码示例。如果您正苦于以下问题:Java ReactBuildConfig类的具体用法?Java ReactBuildConfig怎么用?Java ReactBuildConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ReactBuildConfig类属于com.facebook.react.common.build包,在下文中一共展示了ReactBuildConfig类的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: linkBridge

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
public void linkBridge() {
  if (messagingEnabled) {
    if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      // See isNative in lodash
      String testPostMessageNative = "String(window.postMessage) === String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage')";
      evaluateJavascript(testPostMessageNative, new ValueCallback<String>() {
        @Override
        public void onReceiveValue(String value) {
          if (value.equals("true")) {
            FLog.w(ReactConstants.TAG, "Setting onMessage on a WebView overrides existing values of window.postMessage, but a previous value was defined");
          }
        }
      });
    }

    loadUrl("javascript:(" +
      "window.originalPostMessage = window.postMessage," +
      "window.postMessage = function(data) {" +
        BRIDGE_NAME + ".postMessage(String(data));" +
      "}" +
    ")");
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:24,代码来源:ReactWebViewManager.java


示例2: createJSModules

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  List<Class<? extends JavaScriptModule>> jsModules = new ArrayList<>(Arrays.asList(
      DeviceEventManagerModule.RCTDeviceEventEmitter.class,
      JSTimersExecution.class,
      RCTEventEmitter.class,
      RCTNativeAppEventEmitter.class,
      AppRegistry.class,
      com.facebook.react.bridge.Systrace.class,
      HMRClient.class));

  if (ReactBuildConfig.DEBUG) {
    jsModules.add(DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
    jsModules.add(JSCHeapCapture.HeapCapture.class);
    jsModules.add(JSCSamplingProfiler.SamplingProfiler.class);
  }

  return jsModules;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:20,代码来源:CoreModulesPackage.java


示例3: downloadScriptToFileSync

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
/**
 * Utility method used to help develop web workers on debug builds. In release builds, worker
 * scripts need to be packaged with the app, but in dev mode we want to fetch/reload the worker
 * script on the fly from the packager. This method fetches the given URL *synchronously* and
 * writes it to the specified temp file.
 *
 * This is exposed from Java only because we don't want to add a C++ networking library dependency
 *
 * NB: The caller is responsible for deleting the file specified by outFileName when they're done
 * with it.
 * NB: We write to a temp file instead of returning a String because, depending on the size of the
 * worker script, allocating the full script string on the Java heap can cause an OOM.
 */
@DoNotStrip
public static void downloadScriptToFileSync(String url, String outFileName) {
  if (!ReactBuildConfig.DEBUG) {
    throw new RuntimeException(
        "For security reasons, downloading scripts is only allowed in debug builds.");
  }

  OkHttpClient client = new OkHttpClient();
  final File out = new File(outFileName);

  Request request = new Request.Builder()
      .url(url)
      .build();

  try {
    Response response = client.newCall(request).execute();

    Sink output = Okio.sink(out);
    Okio.buffer(response.body().source()).readAll(output);
  } catch (IOException e) {
    throw new RuntimeException("Exception downloading web worker script to file", e);
  }
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:37,代码来源:WebWorkers.java


示例4: downloadScriptToFileSync

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
/**
 * Utility method used to help develop web workers on debug builds. In release builds, worker
 * scripts need to be packaged with the app, but in dev mode we want to fetch/reload the worker
 * script on the fly from the packager. This method fetches the given URL *synchronously* and
 * writes it to the specified temp file.
 *
 * This is exposed from Java only because we don't want to add a C++ networking library dependency
 *
 * NB: The caller is responsible for deleting the file specified by outFileName when they're done
 * with it.
 * NB: We write to a temp file instead of returning a String because, depending on the size of the
 * worker script, allocating the full script string on the Java heap can cause an OOM.
 */
public static void downloadScriptToFileSync(String url, String outFileName) {
  if (!ReactBuildConfig.DEBUG) {
    throw new RuntimeException(
        "For security reasons, downloading scripts is only allowed in debug builds.");
  }

  OkHttpClient client = new OkHttpClient();
  final File out = new File(outFileName);

  Request request = new Request.Builder()
      .url(url)
      .build();

  try {
    Response response = client.newCall(request).execute();

    Sink output = Okio.sink(out);
    Okio.buffer(response.body().source()).readAll(output);
  } catch (IOException e) {
    throw new RuntimeException("Exception downloading web worker script to file", e);
  }
}
 
开发者ID:ManrajGrover,项目名称:react-native-box-loaders,代码行数:36,代码来源:WebWorkers.java


示例5: createViewInstance

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Override
protected WebView createViewInstance(ThemedReactContext reactContext) {
  ReactWebView webView = new ReactWebView(reactContext);
  webView.setWebChromeClient(new WebChromeClient() {
    @Override
    public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
      callback.invoke(origin, true, false);
    }
  });
  reactContext.addLifecycleEventListener(webView);
  mWebViewConfig.configWebView(webView);
  webView.getSettings().setBuiltInZoomControls(true);
  webView.getSettings().setDisplayZoomControls(false);

  // Fixes broken full-screen modals/galleries due to body height being 0.
  webView.setLayoutParams(
          new LayoutParams(LayoutParams.MATCH_PARENT,
              LayoutParams.MATCH_PARENT));

  if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    WebView.setWebContentsDebuggingEnabled(true);
  }

  return webView;
}
 
开发者ID:Right-Men,项目名称:Ironman,代码行数:26,代码来源:ReactWebViewManager.java


示例6: linkBridge

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
public void linkBridge() {
    if (messagingEnabled) {
        if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            // See isNative in lodash
            String testPostMessageNative = "String(window.postMessage) === String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage')";
            evaluateJavascript(testPostMessageNative, new ValueCallback<String>() {
                @Override
                public void onReceiveValue(String value) {
                    if (value.equals("true")) {
                        FLog.w(ReactConstants.TAG, "Setting onMessage on a WebView overrides existing values of window.postMessage, but a previous value was defined");
                    }
                }
            });
        }

        loadUrl("javascript:(" +
                "window.originalPostMessage = window.postMessage," +
                "window.postMessage = function(data) {" +
                BRIDGE_NAME + ".postMessage(String(data));" +
                "}" +
                ")");
    }
}
 
开发者ID:shimohq,项目名称:react-native-x5,代码行数:24,代码来源:RNX5WebViewManager.java


示例7: createViewInstance

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Override
protected WebView createViewInstance(ThemedReactContext reactContext) {
    X5WeView webView = new X5WeView(reactContext);

    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {
            callback.invoke(origin, true, false);
        }
    });
    reactContext.addLifecycleEventListener(webView);
    mWebViewConfig.configWebView(webView);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setDisplayZoomControls(false);

    // Fixes broken full-screen modals/galleries due to body height being 0.
    webView.setLayoutParams(
            new LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.MATCH_PARENT));

    if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    return webView;
}
 
开发者ID:shimohq,项目名称:react-native-x5,代码行数:27,代码来源:RNX5WebViewManager.java


示例8: createViewInstance

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Override
protected WebView createViewInstance(ThemedReactContext reactContext) {
  ReactWebView webView = new ReactWebView(reactContext);
  webView.setWebChromeClient(new WebChromeClient() {
    @Override
    public boolean onConsoleMessage(ConsoleMessage message) {
      if (ReactBuildConfig.DEBUG) {
        return super.onConsoleMessage(message);
      }
      // Ignore console logs in non debug builds.
      return true;
    }

    @Override
    public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
      callback.invoke(origin, true, false);
    }
  });
  reactContext.addLifecycleEventListener(webView);
  mWebViewConfig.configWebView(webView);
  webView.getSettings().setBuiltInZoomControls(true);
  webView.getSettings().setDisplayZoomControls(false);
  webView.getSettings().setDomStorageEnabled(true);

  // Fixes broken full-screen modals/galleries due to body height being 0.
  webView.setLayoutParams(
          new LayoutParams(LayoutParams.MATCH_PARENT,
              LayoutParams.MATCH_PARENT));

  if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    WebView.setWebContentsDebuggingEnabled(true);
  }

  return webView;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:36,代码来源:ReactWebViewManager.java


示例9: warnImageSource

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
private void warnImageSource(String uri) {
  if (ReactBuildConfig.DEBUG) {
    Toast.makeText(
      getContext(),
      "Warning: Image source \"" + uri + "\" doesn't exist",
      Toast.LENGTH_SHORT).show();
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:9,代码来源:ReactImageView.java


示例10: ConstructorProvider

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
public ConstructorProvider(Class<? extends NativeModule> type, Class[] signature) {
  if (ReactBuildConfig.DEBUG) {
    try {
      mConstructor = getConstructor(type, signature);
    } catch (NoSuchMethodException e) {
      throw new IllegalArgumentException("No such constructor", e);
    }
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:10,代码来源:ModuleSpec.java


示例11: JavaScriptModuleRegistration

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
public JavaScriptModuleRegistration(Class<? extends JavaScriptModule> moduleInterface) {
  mModuleInterface = moduleInterface;

  if (ReactBuildConfig.DEBUG) {
    Set<String> methodNames = new LinkedHashSet<>();
    for (Method method : mModuleInterface.getDeclaredMethods()) {
      if (!methodNames.add(method.getName())) {
        throw new AssertionError(
          "Method overloading is unsupported: " + mModuleInterface.getName() + "#" +
            method.getName());
      }
    }
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:15,代码来源:JavaScriptModuleRegistration.java


示例12: onBaseContextAttached

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Override
protected void onBaseContextAttached() {
  // This is a terrible hack.  Don't copy it.
  // It's unfortunate that Instagram does the same thing.
  // We need to do this here because internal apps use SoLoader,
  // and Open Source Buck uses ExopackageSoLoader.
  // If you feel the need to copy this, we should refactor it
  // into an FB-specific subclass of ExopackageApplication.
  SoLoader.init(this, (ReactBuildConfig.EXOPACKAGE_FLAGS & 2) != 0);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:11,代码来源:ReactTestAppShell.java


示例13: testSimpleContextConstructor

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Test
public void testSimpleContextConstructor() {
  Whitebox.setInternalState(ReactBuildConfig.class, "DEBUG", true);
  ReactApplicationContext context = mock(ReactApplicationContext.class);
  ModuleSpec spec = ModuleSpec.simple(SimpleContextModule.class, context);

  NativeModule module = spec.getProvider().get();
  assertThat(module).isInstanceOf(SimpleContextModule.class);
  SimpleContextModule contextModule = (SimpleContextModule) module;
  assertThat(contextModule.getReactApplicationContext()).isSameAs(context);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:12,代码来源:ModuleSpecTest.java


示例14: createViewInstance

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Override
protected WebView createViewInstance(ThemedReactContext reactContext) {
  ReactWebView webView = new ReactWebView(reactContext);
  reactContext.addLifecycleEventListener(webView);
  mWebViewConfig.configWebView(webView);

  if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    WebView.setWebContentsDebuggingEnabled(true);
  }

  return webView;
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:13,代码来源:ReactWebViewManager.java


示例15: createViewInstance

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Override
protected WebView createViewInstance(ThemedReactContext reactContext) {
    MagnetWebView magnetWebView = new MagnetWebView(mContext);
    reactContext.addLifecycleEventListener(magnetWebView);

    if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    return magnetWebView;
}
 
开发者ID:mozilla-magnet,项目名称:magnet-client,代码行数:12,代码来源:MagnetWebViewManager.java


示例16: createViewInstance

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Override
protected WebView createViewInstance(ThemedReactContext reactContext) {
  ReactWebView webView = new ReactWebView(reactContext);
  webView.setWebChromeClient(new WebChromeClient());
  reactContext.addLifecycleEventListener(webView);
  mWebViewConfig.configWebView(webView);

  if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    WebView.setWebContentsDebuggingEnabled(true);
  }

  return webView;
}
 
开发者ID:ManrajGrover,项目名称:react-native-box-loaders,代码行数:14,代码来源:ReactWebViewManager.java


示例17: ReactTestAppShell

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
public ReactTestAppShell() {
  super("com.facebook.react.testing.ReactTestApplicationImpl", ReactBuildConfig.EXOPACKAGE_FLAGS);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:4,代码来源:ReactTestAppShell.java


示例18: testSimpleFailFast

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testSimpleFailFast() {
  Whitebox.setInternalState(ReactBuildConfig.class, "DEBUG", true);
  ModuleSpec.simple(ComplexModule.class, mock(ReactApplicationContext.class));
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:6,代码来源:ModuleSpecTest.java


示例19: testSimpleFailFastDefault

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testSimpleFailFastDefault() {
  Whitebox.setInternalState(ReactBuildConfig.class, "DEBUG", true);
  ModuleSpec.simple(ComplexModule.class);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:6,代码来源:ModuleSpecTest.java


示例20: testSimpleNoFailFastRelease

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Test
public void testSimpleNoFailFastRelease() {
  Whitebox.setInternalState(ReactBuildConfig.class, "DEBUG", false);
  ModuleSpec.simple(ComplexModule.class, mock(ReactApplicationContext.class));
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:6,代码来源:ModuleSpecTest.java


示例21: testSimpleFailLateRelease

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Test(expected = RuntimeException.class)
public void testSimpleFailLateRelease() {
  Whitebox.setInternalState(ReactBuildConfig.class, "DEBUG", false);
  ModuleSpec spec = ModuleSpec.simple(ComplexModule.class, mock(ReactApplicationContext.class));
  spec.getProvider().get();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:7,代码来源:ModuleSpecTest.java


示例22: testSimpleDefaultConstructor

import com.facebook.react.common.build.ReactBuildConfig; //导入依赖的package包/类
@Test
public void testSimpleDefaultConstructor() {
  Whitebox.setInternalState(ReactBuildConfig.class, "DEBUG", true);
  ModuleSpec spec = ModuleSpec.simple(SimpleModule.class);
  assertThat(spec.getProvider().get()).isInstanceOf(SimpleModule.class);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:7,代码来源:ModuleSpecTest.java



注:本文中的com.facebook.react.common.build.ReactBuildConfig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。