covert RNFeedPackage and it's modules to use @ReactModule and @ReactModuleList

Reviewed By: lexs

Differential Revision: D3796860

fbshipit-source-id: d4b5f3635754ef28277b79cb1ea9bab07ba3ea6e
This commit is contained in:
Aaron Chiu 2016-09-02 16:15:11 -07:00 committed by Facebook Github Bot 2
parent 6c909ef80d
commit 3d1b79cd15
53 changed files with 219 additions and 134 deletions

View File

@ -6,13 +6,14 @@ android_library(
'*.java',
]),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/modules/core:core'),
react_native_target('java/com/facebook/react/uimanager:uimanager'),
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),
react_native_dep('third-party/android/support/v4:lib-support-v4'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_dep('third-party/android/support/v4:lib-support-v4'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/modules/core:core'),
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),
react_native_target('java/com/facebook/react/uimanager:uimanager'),
],
visibility = [
'PUBLIC',

View File

@ -21,6 +21,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.uimanager.GuardedChoreographerFrameCallback;
import com.facebook.react.uimanager.ReactChoreographer;
@ -70,6 +71,7 @@ import java.util.ArrayList;
* isolates us from the problems that may be caused by concurrent updates of animated graph while UI
* thread is "executing" the animation loop.
*/
@ReactModule(name = "NativeAnimatedModule")
public class NativeAnimatedModule extends ReactContextBaseJavaModule implements
OnBatchCompleteListener, LifecycleEventListener {
@ -136,8 +138,8 @@ public class NativeAnimatedModule extends ReactContextBaseJavaModule implements
// from the UIManagerModule) doesn't matter as we only enqueue operations for the UI thread to
// be executed from here. Thanks to ReactChoreographer all the operations from here are going
// to be executed *after* all the operations enqueued by UIManager as the callback type that we
// use for ReactChoreographer (CallbackType.NATIVE_ANIMATED_MODULE) is run after callbacks that UIManager
// use
// use for ReactChoreographer (CallbackType.NATIVE_ANIMATED_MODULE) is run after callbacks that
// UIManager uses.
ArrayList<UIThreadOperation> operations = mOperations.isEmpty() ? null : mOperations;
if (operations != null) {
mOperations = new ArrayList<>();

View File

@ -4,6 +4,7 @@ package com.facebook.react.module.processing;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
@ -37,6 +38,7 @@ import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import static javax.lang.model.element.Modifier.PUBLIC;
import static javax.tools.Diagnostic.Kind.ERROR;
/**
* Generates a list of ReactModuleInfo for modules annotated with {@link ReactModule} in
@ -59,6 +61,8 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
private Filer mFiler;
@SuppressFieldNotInitialized
private Elements mElements;
@SuppressFieldNotInitialized
private Messager mMessager;
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
@ -66,6 +70,7 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
mFiler = processingEnv.getFiler();
mElements = processingEnv.getElementUtils();
mMessager = processingEnv.getMessager();
}
@Override
@ -89,23 +94,29 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
}
}
MethodSpec getReactModuleInfosMethod = MethodSpec.methodBuilder("getReactModuleInfos")
.addModifiers(PUBLIC)
// TODO add function to native module interface
MethodSpec getReactModuleInfosMethod;
try {
getReactModuleInfosMethod = MethodSpec.methodBuilder("getReactModuleInfos")
.addModifiers(PUBLIC)
// TODO add function to native module interface
// .addAnnotation(Override.class)
.addCode(getCodeBlockForReactModuleInfos(nativeModules))
.returns(MAP_TYPE)
.build();
.addCode(getCodeBlockForReactModuleInfos(nativeModules))
.returns(MAP_TYPE)
.build();
} catch (ReactModuleSpecException reactModuleSpecException) {
mMessager.printMessage(ERROR, reactModuleSpecException.mMessage);
return false;
}
TypeSpec reactModulesInfosTypeSpec = TypeSpec.classBuilder(
fileName + "$$ReactModuleInfoProvider")
.addModifiers(Modifier.PUBLIC)
.addMethod(getReactModuleInfosMethod)
.build();
TypeSpec reactModulesInfosTypeSpec = TypeSpec.classBuilder(
fileName + "$$ReactModuleInfoProvider")
.addModifiers(Modifier.PUBLIC)
.addMethod(getReactModuleInfosMethod)
.build();
JavaFile javaFile = JavaFile.builder(packageName, reactModulesInfosTypeSpec)
.addFileComment("Generated by " + getClass().getName())
.build();
JavaFile javaFile = JavaFile.builder(packageName, reactModulesInfosTypeSpec)
.addFileComment("Generated by " + getClass().getName())
.build();
try {
javaFile.writeTo(mFiler);
@ -117,7 +128,8 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
return true;
}
private CodeBlock getCodeBlockForReactModuleInfos(List<String> nativeModules) {
private CodeBlock getCodeBlockForReactModuleInfos(List<String> nativeModules)
throws ReactModuleSpecException {
CodeBlock.Builder builder = CodeBlock.builder()
.addStatement("$T map = new $T()", MAP_TYPE, INSTANTIATED_MAP_TYPE);
@ -126,6 +138,9 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
TypeElement typeElement = mElements.getTypeElement(nativeModule);
ReactModule reactModule = typeElement.getAnnotation(ReactModule.class);
if (reactModule == null) {
throw new ReactModuleSpecException(keyString + " not found.");
}
String valueString = new StringBuilder()
.append("new ReactModuleInfo(")
.append("\"").append(reactModule.name()).append("\"").append(", ")
@ -140,4 +155,13 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
builder.addStatement("return map");
return builder.build();
}
private static class ReactModuleSpecException extends Exception {
public final String mMessage;
public ReactModuleSpecException(String message) {
mMessage = message;
}
}
}

View File

@ -16,8 +16,10 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
@ReactModule(name = "AppState")
public class AppStateModule extends ReactContextBaseJavaModule
implements LifecycleEventListener {

View File

@ -4,12 +4,13 @@ android_library(
name = 'appstate',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/modules/core:core'),
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/modules/core:core'),
],
visibility = [
'PUBLIC',

View File

@ -4,11 +4,12 @@ android_library(
name = 'camera',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
],
visibility = [
'PUBLIC',

View File

@ -49,12 +49,14 @@ import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.module.annotations.ReactModule;
// TODO #6015104: rename to something less iOSish
/**
* {@link NativeModule} that allows JS to interact with the photos on the device (i.e.
* {@link MediaStore.Images}).
*/
@ReactModule(name = "RKCameraRollManager")
public class CameraRollManager extends ReactContextBaseJavaModule {
private static final String ERROR_UNABLE_TO_LOAD = "E_UNABLE_TO_LOAD";

View File

@ -47,10 +47,12 @@ import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.module.annotations.ReactModule;
/**
* Native module that provides image cropping functionality.
*/
@ReactModule(name = "RKImageEditingManager")
public class ImageEditingManager extends ReactContextBaseJavaModule {
private static final List<String> LOCAL_URI_PREFIXES = Arrays.asList(
@ -89,7 +91,6 @@ public class ImageEditingManager extends ReactContextBaseJavaModule {
ExifInterface.TAG_WHITE_BALANCE
};
public ImageEditingManager(ReactApplicationContext reactContext) {
super(reactContext);
new CleanTask(getReactApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
@ -282,7 +283,6 @@ public class ImageEditingManager extends ReactContextBaseJavaModule {
}
mSuccess.invoke(Uri.fromFile(tempFile).toString());
} catch (Exception e) {
mError.invoke(e.getMessage());
}

View File

@ -27,7 +27,9 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.module.annotations.ReactModule;
@ReactModule(name = "ImageStoreManager")
public class ImageStoreManager extends ReactContextBaseJavaModule {
private static final int BUFFER_SIZE = 8192;

View File

@ -4,11 +4,12 @@ android_library(
name = 'clipboard',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
],
visibility = [
'PUBLIC',

View File

@ -14,24 +14,16 @@ import android.content.ClipboardManager;
import android.content.ClipData;
import android.os.Build;
import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Promise;
import com.facebook.react.common.ReactConstants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.facebook.react.module.annotations.ReactModule;
/**
* A module that allows JS to get/set clipboard contents.
*/
@ReactModule(name = "Clipboard")
public class ClipboardModule extends ReactContextBaseJavaModule {
public ClipboardModule(ReactApplicationContext reactContext) {
@ -48,7 +40,7 @@ public class ClipboardModule extends ReactContextBaseJavaModule {
}
@ReactMethod
public void getString(Promise promise){
public void getString(Promise promise) {
try {
ClipboardManager clipboard = getClipboardService();
ClipData clipData = clipboard.getPrimaryClip();
@ -60,7 +52,7 @@ public class ClipboardModule extends ReactContextBaseJavaModule {
} else {
promise.resolve("");
}
} catch(Exception e) {
} catch (Exception e) {
promise.reject(e);
}
}

View File

@ -4,13 +4,14 @@ android_library(
name = 'core',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/devsupport:devsupport'),
react_native_target('java/com/facebook/react/uimanager:uimanager'),
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/devsupport:devsupport'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/uimanager:uimanager'),
],
visibility = [
'PUBLIC',

View File

@ -21,10 +21,12 @@ import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.SupportsWebWorkers;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.module.annotations.ReactModule;
/**
* Native module that handles device hardware events like hardware back presses.
*/
@ReactModule(name = "DeviceEventManager")
public class DeviceEventManagerModule extends ReactContextBaseJavaModule {
@SupportsWebWorkers

View File

@ -21,7 +21,9 @@ import com.facebook.react.bridge.ReadableType;
import com.facebook.react.devsupport.DevSupportManager;
import com.facebook.react.common.JavascriptException;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.module.annotations.ReactModule;
@ReactModule(name = "RKExceptionsManager")
public class ExceptionsManagerModule extends BaseJavaModule {
static private final Pattern mJsModuleIdPattern = Pattern.compile("(?:^|[/\\\\])(\\d+\\.js)$");

View File

@ -24,6 +24,7 @@ import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.common.SystemClock;
import com.facebook.react.devsupport.DevSupportManager;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.ReactChoreographer;
import java.util.ArrayList;
@ -41,6 +42,7 @@ import javax.annotation.Nullable;
/**
* Native module for JS timer execution. Timers fire on frame boundaries.
*/
@ReactModule(name = "RCTTiming", supportsWebWorkers = true)
public final class Timing extends ReactContextBaseJavaModule implements LifecycleEventListener,
OnExecutorUnregisteredListener {
@ -168,7 +170,7 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl
long time = SystemClock.currentTimeMillis();
long absoluteFrameStartTime = time - frameTimeElapsed;
if (FRAME_DURATION_MS - (float)frameTimeElapsed < IDLE_CALLBACK_FRAME_DEADLINE_MS) {
if (FRAME_DURATION_MS - (float) frameTimeElapsed < IDLE_CALLBACK_FRAME_DEADLINE_MS) {
return;
}

View File

@ -4,11 +4,12 @@ android_library(
name = 'datepicker',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_dep('third-party/android/support/v4:lib-support-v4'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
],
visibility = [
'PUBLIC',

View File

@ -31,11 +31,13 @@ import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.module.annotations.ReactModule;
/**
* {@link NativeModule} that allows JS to show a native date picker dialog and get called back when
* the user selects a date.
*/
@ReactModule(name = "DatePickerAndroid")
public class DatePickerDialogModule extends ReactContextBaseJavaModule {
@VisibleForTesting
@ -129,7 +131,7 @@ public class DatePickerDialogModule extends ReactContextBaseJavaModule {
android.support.v4.app.FragmentManager fragmentManager =
((android.support.v4.app.FragmentActivity) activity).getSupportFragmentManager();
android.support.v4.app.DialogFragment oldFragment =
(android.support.v4.app.DialogFragment)fragmentManager.findFragmentByTag(FRAGMENT_TAG);
(android.support.v4.app.DialogFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG);
if (oldFragment != null) {
oldFragment.dismiss();
}
@ -144,7 +146,7 @@ public class DatePickerDialogModule extends ReactContextBaseJavaModule {
fragment.show(fragmentManager, FRAGMENT_TAG);
} else {
FragmentManager fragmentManager = activity.getFragmentManager();
DialogFragment oldFragment = (DialogFragment)fragmentManager.findFragmentByTag(FRAGMENT_TAG);
DialogFragment oldFragment = (DialogFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG);
if (oldFragment != null) {
oldFragment.dismiss();
}

View File

@ -23,11 +23,13 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.module.annotations.ReactModule;
/**
* Module that records debug information during transitions (animated navigation events such as
* going from one screen to another).
*/
@ReactModule(name = "AnimationsDebugModule")
public class AnimationsDebugModule extends ReactContextBaseJavaModule {
private @Nullable FpsDebugFrameCallback mFrameCallback;

View File

@ -4,12 +4,13 @@ android_library(
name = 'debug',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/uimanager:uimanager'),
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/uimanager:uimanager'),
],
visibility = [
'PUBLIC',

View File

@ -14,15 +14,13 @@ import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.module.annotations.ReactModule;
/**
* Module that exposes the URL to the source code map (used for exception stack trace parsing) to JS
*/
@ReactModule(name = "RCTSourceCode")
public class SourceCodeModule extends BaseJavaModule {
private final String mSourceUrl;
@ -38,7 +36,7 @@ public class SourceCodeModule extends BaseJavaModule {
@Override
public @Nullable Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<String, Object>();
HashMap<String, Object> constants = new HashMap<>();
constants.put("scriptURL", mSourceUrl);
return constants;
}

View File

@ -4,12 +4,13 @@ android_library(
name = 'dialog',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
react_native_dep('third-party/android/support/v4:lib-support-v4'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
],
visibility = [
'PUBLIC',

View File

@ -21,7 +21,6 @@ import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
@ -30,7 +29,9 @@ import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.module.annotations.ReactModule;
@ReactModule(name = DialogModule.NAME)
public class DialogModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
/* package */ static final String FRAGMENT_TAG =

View File

@ -18,6 +18,7 @@ android_library(
react_native_dep('third-party/java/okhttp:okhttp3'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/modules/common:common'),
react_native_target('java/com/facebook/react/modules/network:network'),
],

View File

@ -23,6 +23,7 @@ import com.facebook.imagepipeline.listener.RequestListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.modules.common.ModuleDataCleaner;
import com.facebook.react.modules.network.OkHttpClientProvider;
import com.facebook.soloader.SoLoader;
@ -32,6 +33,7 @@ import com.facebook.soloader.SoLoader;
*
* <p>Does not expose any methods to JavaScript code. For initialization and cleanup only.
*/
@ReactModule(name = "FrescoModule")
public class FrescoModule extends ReactContextBaseJavaModule implements
ModuleDataCleaner.Cleanable {

View File

@ -9,6 +9,7 @@ android_library(
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
],
visibility = [
'PUBLIC',

View File

@ -13,18 +13,18 @@ import android.content.Context;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.module.annotations.ReactModule;
import java.util.Locale;
import java.util.Map;
/**
* {@link NativeModule} that allows JS to set allowRTL and get isRTL status.
*/
@ReactModule(name = "I18nManager")
public class I18nManagerModule extends ReactContextBaseJavaModule {
private final I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
@ -44,9 +44,7 @@ public class I18nManagerModule extends ReactContextBaseJavaModule {
final Locale locale = context.getResources().getConfiguration().locale;
final Map<String, Object> constants = MapBuilder.newHashMap();
constants.put("isRTL", sharedI18nUtilInstance.isRTL(
getReactApplicationContext()
));
constants.put("isRTL", sharedI18nUtilInstance.isRTL(getReactApplicationContext()));
constants.put("localeIdentifier", locale.toString());
return constants;
}
@ -55,15 +53,13 @@ public class I18nManagerModule extends ReactContextBaseJavaModule {
public void allowRTL(boolean value) {
sharedI18nUtilInstance.allowRTL(
getReactApplicationContext(),
value
);
value);
}
@ReactMethod
public void forceRTL(boolean value) {
sharedI18nUtilInstance.forceRTL(
getReactApplicationContext(),
value
);
value);
}
}

View File

@ -12,6 +12,7 @@ android_library(
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
],
visibility = [
'PUBLIC',

View File

@ -33,7 +33,9 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.module.annotations.ReactModule;
@ReactModule(name = "ImageLoader")
public class ImageLoaderModule extends ReactContextBaseJavaModule implements
LifecycleEventListener {

View File

@ -4,10 +4,11 @@ android_library(
name = 'intent',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
],
visibility = [
'PUBLIC',

View File

@ -19,10 +19,12 @@ import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.module.annotations.ReactModule;
/**
* Intent module. Launch other activities or open URLs.
*/
@ReactModule(name = "IntentAndroid")
public class IntentModule extends ReactContextBaseJavaModule {
public IntentModule(ReactApplicationContext reactContext) {

View File

@ -4,11 +4,12 @@ android_library(
name = 'location',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/modules/core:core'),
react_native_target('java/com/facebook/react/common:common'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/modules/core:core'),
],
visibility = [
'PUBLIC',

View File

@ -28,11 +28,13 @@ import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.common.SystemClock;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
/**
* Native module that exposes Geolocation to JS.
*/
@ReactModule(name = "LocationObserver")
public class LocationModule extends ReactContextBaseJavaModule {
private @Nullable String mWatchedProvider;
@ -76,7 +78,11 @@ public class LocationModule extends ReactContextBaseJavaModule {
private final boolean highAccuracy;
private final float distanceFilter;
private LocationOptions(long timeout, double maximumAge, boolean highAccuracy, float distanceFilter) {
private LocationOptions(
long timeout,
double maximumAge,
boolean highAccuracy,
float distanceFilter) {
this.timeout = timeout;
this.maximumAge = maximumAge;
this.highAccuracy = highAccuracy;
@ -91,8 +97,9 @@ public class LocationModule extends ReactContextBaseJavaModule {
map.hasKey("maximumAge") ? map.getDouble("maximumAge") : Double.POSITIVE_INFINITY;
boolean highAccuracy =
map.hasKey("enableHighAccuracy") && map.getBoolean("enableHighAccuracy");
float distanceFilter =
map.hasKey("distanceFilter") ? (float) map.getDouble("distanceFilter") : RCT_DEFAULT_LOCATION_ACCURACY;
float distanceFilter = map.hasKey("distanceFilter") ?
(float) map.getDouble("distanceFilter") :
RCT_DEFAULT_LOCATION_ACCURACY;
return new LocationOptions(timeout, maximumAge, highAccuracy, distanceFilter);
}
@ -156,7 +163,11 @@ public class LocationModule extends ReactContextBaseJavaModule {
}
if (!provider.equals(mWatchedProvider)) {
locationManager.removeUpdates(mLocationListener);
locationManager.requestLocationUpdates(provider, 1000, locationOptions.distanceFilter, mLocationListener);
locationManager.requestLocationUpdates(
provider,
1000,
locationOptions.distanceFilter,
mLocationListener);
}
mWatchedProvider = provider;
} catch (SecurityException e) {

View File

@ -4,13 +4,14 @@ android_library(
name = 'netinfo',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/modules/core:core'),
react_native_target('java/com/facebook/react/common:common'),
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
react_native_dep('third-party/android/support/v4:lib-support-v4'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/modules/core:core'),
],
visibility = [
'PUBLIC',

View File

@ -24,12 +24,14 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.module.annotations.ReactModule;
import static com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
/**
* Module that monitors and provides information about the connectivity state of the device.
*/
@ReactModule(name = "NetInfo")
public class NetInfoModule extends ReactContextBaseJavaModule
implements LifecycleEventListener {

View File

@ -50,7 +50,7 @@ import okhttp3.ResponseBody;
/**
* Implements the XMLHttpRequest JavaScript interface.
*/
@ReactModule(name = "RCTNetworking")
@ReactModule(name = "RCTNetworking", supportsWebWorkers = true)
public final class NetworkingModule extends ReactContextBaseJavaModule {
private static final String CONTENT_ENCODING_HEADER_NAME = "content-encoding";

View File

@ -4,11 +4,12 @@ android_library(
name = 'permissions',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/modules/core:core'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/modules/core:core'),
],
visibility = [
'PUBLIC',

View File

@ -20,12 +20,14 @@ import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.modules.core.PermissionAwareActivity;
import com.facebook.react.modules.core.PermissionListener;
/**
* Module that exposes the Android M Permission system to JS.
*/
@ReactModule(name = "PermissionsAndroid")
public class PermissionsModule extends ReactContextBaseJavaModule implements PermissionListener {
private final SparseArray<Callback> mCallbacks;

View File

@ -4,11 +4,12 @@ android_library(
name = 'share',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
],
visibility = [
'PUBLIC',

View File

@ -11,21 +11,20 @@ package com.facebook.react.modules.share;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.module.annotations.ReactModule;
/**
* Intent module. Launch other activities or open URLs.
*/
@ReactModule(name = "ShareModule")
public class ShareModule extends ReactContextBaseJavaModule {
/* package */ static final String ACTION_SHARED = "sharedAction";
@ -80,11 +79,8 @@ public class ShareModule extends ReactContextBaseJavaModule {
WritableMap result = Arguments.createMap();
result.putString("action", ACTION_SHARED);
promise.resolve(result);
} catch (Exception e) {
promise.reject(ERROR_UNABLE_TO_OPEN_DIALOG, "Failed to open share dialog");
}
}
}
}

View File

@ -4,12 +4,13 @@ android_library(
name = 'statusbar',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/uimanager:uimanager'),
react_native_dep('third-party/android/support/v4:lib-support-v4'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/uimanager:uimanager'),
],
visibility = [
'PUBLIC',

View File

@ -30,11 +30,13 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.PixelUtil;
/**
* {@link NativeModule} that allows changing the appearance of the status bar.
*/
@ReactModule(name = "StatusBarManager")
public class StatusBarModule extends ReactContextBaseJavaModule {
private static final String ERROR_NO_ACTIVITY = "E_NO_ACTIVITY";
@ -55,14 +57,14 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
@Override
public @Nullable Map<String, Object> getConstants() {
final Context context = getReactApplicationContext();
final int heightResId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
final int heightResId = context.getResources()
.getIdentifier("status_bar_height", "dimen", "android");
final float height = heightResId > 0 ?
PixelUtil.toDIPFromPixel(context.getResources().getDimensionPixelSize(heightResId)) :
0;
return MapBuilder.<String, Object>of(
HEIGHT_KEY, height
);
HEIGHT_KEY, height);
}
@ReactMethod
@ -99,8 +101,7 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
}
res.resolve(null);
}
}
);
});
} else {
res.resolve(null);
}
@ -132,8 +133,7 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
defaultInsets.getSystemWindowInsetLeft(),
0,
defaultInsets.getSystemWindowInsetRight(),
defaultInsets.getSystemWindowInsetBottom()
);
defaultInsets.getSystemWindowInsetBottom());
}
});
} else {
@ -143,8 +143,7 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
ViewCompat.requestApplyInsets(decorView);
res.resolve(null);
}
}
);
});
}
}
@ -169,7 +168,6 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
res.resolve(null);
}
}
);
});
}
}

View File

@ -26,12 +26,14 @@ import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.SetBuilder;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.modules.common.ModuleDataCleaner;
import static com.facebook.react.modules.storage.ReactDatabaseSupplier.KEY_COLUMN;
import static com.facebook.react.modules.storage.ReactDatabaseSupplier.TABLE_CATALYST;
import static com.facebook.react.modules.storage.ReactDatabaseSupplier.VALUE_COLUMN;
@ReactModule(name = "AsyncSQLiteDBStorage")
public final class AsyncStorageModule
extends ReactContextBaseJavaModule implements ModuleDataCleaner.Cleanable {

View File

@ -4,12 +4,13 @@ android_library(
name = 'storage',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/modules/common:common'),
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/modules/common:common'),
],
visibility = [
'PUBLIC',

View File

@ -12,6 +12,7 @@ package com.facebook.react.modules.systeminfo;
import android.os.Build;
import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.module.annotations.ReactModule;
import java.util.HashMap;
import java.util.Map;
@ -21,6 +22,7 @@ import javax.annotation.Nullable;
/**
* Module that exposes Android Constants to JS.
*/
@ReactModule(name = "AndroidConstants")
public class AndroidInfoModule extends BaseJavaModule {
@Override
@ -30,7 +32,7 @@ public class AndroidInfoModule extends BaseJavaModule {
@Override
public @Nullable Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<String, Object>();
HashMap<String, Object> constants = new HashMap<>();
constants.put("Version", Build.VERSION.SDK_INT);
constants.put("ServerHost", AndroidInfoHelpers.getServerHost());
return constants;

View File

@ -4,10 +4,11 @@ android_library(
name = 'systeminfo',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
],
visibility = [
'PUBLIC',

View File

@ -4,11 +4,12 @@ android_library(
name = 'timepicker',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_dep('third-party/android/support/v4:lib-support-v4'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
],
visibility = [
'PUBLIC',

View File

@ -11,8 +11,6 @@ package com.facebook.react.modules.timepicker;
import javax.annotation.Nullable;
import java.util.Map;
import android.app.Activity;
import android.app.DialogFragment;
import android.app.FragmentManager;
@ -31,11 +29,13 @@ import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.module.annotations.ReactModule;
/**
* {@link NativeModule} that allows JS to show a native time picker dialog and get called back when
* the user selects a time.
*/
@ReactModule(name = "TimePickerAndroid")
public class TimePickerDialogModule extends ReactContextBaseJavaModule {
@VisibleForTesting
@ -106,7 +106,7 @@ public class TimePickerDialogModule extends ReactContextBaseJavaModule {
android.support.v4.app.FragmentManager fragmentManager =
((android.support.v4.app.FragmentActivity) activity).getSupportFragmentManager();
android.support.v4.app.DialogFragment oldFragment =
(android.support.v4.app.DialogFragment)fragmentManager.findFragmentByTag(FRAGMENT_TAG);
(android.support.v4.app.DialogFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG);
if (oldFragment != null) {
oldFragment.dismiss();
}

View File

@ -4,10 +4,11 @@ android_library(
name = 'toast',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
],
visibility = [
'PUBLIC',

View File

@ -18,12 +18,14 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.module.annotations.ReactModule;
import java.util.Map;
/**
* {@link NativeModule} that allows JS to show an Android Toast.
*/
@ReactModule(name = "ToastAndroid")
public class ToastModule extends ReactContextBaseJavaModule {
private static final String DURATION_SHORT_KEY = "SHORT";

View File

@ -4,12 +4,13 @@ android_library(
name = 'vibration',
srcs = glob(['**/*.java']),
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/modules/core:core'),
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/modules/core:core'),
],
visibility = [
'PUBLIC',

View File

@ -16,7 +16,9 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.module.annotations.ReactModule;
@ReactModule(name = "Vibration")
public class VibrationModule extends ReactContextBaseJavaModule {
public VibrationModule(ReactApplicationContext reactContext) {

View File

@ -12,6 +12,7 @@ android_library(
react_native_dep('third-party/java/okio:okio'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/modules/core:core'),
],
visibility = [

View File

@ -27,6 +27,7 @@ import com.facebook.react.bridge.ReadableMapKeySetIterator;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import okhttp3.OkHttpClient;
@ -47,9 +48,11 @@ import java.util.concurrent.TimeUnit;
import okio.Buffer;
import okio.ByteString;
@ReactModule(name = "WebSocketModule")
public class WebSocketModule extends ReactContextBaseJavaModule {
private Map<Integer, WebSocket> mWebSocketConnections = new HashMap<>();
private final Map<Integer, WebSocket> mWebSocketConnections = new HashMap<>();
private ReactContext mReactContext;
public WebSocketModule(ReactApplicationContext context) {
@ -69,7 +72,11 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
}
@ReactMethod
public void connect(final String url, @Nullable final ReadableArray protocols, @Nullable final ReadableMap headers, final int id) {
public void connect(
final String url,
@Nullable final ReadableArray protocols,
@Nullable final ReadableMap headers,
final int id) {
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)
.writeTimeout(10, TimeUnit.SECONDS)
@ -219,7 +226,8 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
throw new RuntimeException("Cannot send a message. Unknown WebSocket id " + id);
}
try {
client.sendMessage(RequestBody.create(WebSocket.BINARY, ByteString.decodeBase64(base64String)));
client.sendMessage(
RequestBody.create(WebSocket.BINARY, ByteString.decodeBase64(base64String)));
} catch (IOException | IllegalStateException e) {
notifyWebSocketFailed(id, e.getMessage());
}
@ -267,16 +275,18 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
}
if (requestURI.getPort() != -1) {
defaultOrigin = String.format("%s://%s:%s", scheme, requestURI.getHost(), requestURI.getPort());
defaultOrigin = String.format(
"%s://%s:%s",
scheme,
requestURI.getHost(),
requestURI.getPort());
} else {
defaultOrigin = String.format("%s://%s/", scheme, requestURI.getHost());
}
return defaultOrigin;
} catch(URISyntaxException e) {
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Unable to set " + uri + " as default origin header.");
}
}
}