本文整理汇总了Java中com.facebook.react.common.build.ReactBuildConfig.DEBUG属性的典型用法代码示例。如果您正苦于以下问题:Java ReactBuildConfig.DEBUG属性的具体用法?Java ReactBuildConfig.DEBUG怎么用?Java ReactBuildConfig.DEBUG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.facebook.react.common.build.ReactBuildConfig
的用法示例。
在下文中一共展示了ReactBuildConfig.DEBUG属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: linkBridge
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));" +
"}" +
")");
}
}
示例2: createJSModules
@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;
}
示例3: downloadScriptToFileSync
/**
* 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);
}
}
示例4: downloadScriptToFileSync
/**
* 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);
}
}
示例5: createViewInstance
@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;
}
示例6: linkBridge
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));" +
"}" +
")");
}
}
示例7: createViewInstance
@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;
}
示例8: createViewInstance
@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;
}
示例9: warnImageSource
private void warnImageSource(String uri) {
if (ReactBuildConfig.DEBUG) {
Toast.makeText(
getContext(),
"Warning: Image source \"" + uri + "\" doesn't exist",
Toast.LENGTH_SHORT).show();
}
}
示例10: ConstructorProvider
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);
}
}
}
示例11: JavaScriptModuleRegistration
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());
}
}
}
}
示例12: createViewInstance
@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;
}
示例13: createViewInstance
@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;
}
示例14: createViewInstance
@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;
}