Cleanup 4/4
Summary: I think that's it. Some more minor changes and removing an unused BUCK file. Reviewed By: mweststrate Differential Revision: D19471282 fbshipit-source-id: ceb85111f03a41141dca0bdd445cda12dfbac1c4
This commit is contained in:
committed by
Facebook Github Bot
parent
2ec539acb1
commit
3d66df2d86
@@ -14,6 +14,7 @@ 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;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* The FlipperModule is a React Native Native Module. The instance handles incoming calls that
|
||||
@@ -27,15 +28,16 @@ public class FlipperModule extends ReactContextBaseJavaModule {
|
||||
|
||||
public static final String NAME = "Flipper";
|
||||
|
||||
private FlipperReactNativeJavaScriptPluginManager manager;
|
||||
private final FlipperReactNativeJavaScriptPluginManager mManager;
|
||||
|
||||
public FlipperModule(
|
||||
FlipperModule(
|
||||
FlipperReactNativeJavaScriptPluginManager manager, ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
this.manager = manager;
|
||||
mManager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
@@ -43,41 +45,41 @@ public class FlipperModule extends ReactContextBaseJavaModule {
|
||||
@ReactMethod
|
||||
public void registerPlugin(
|
||||
final String pluginId, final Boolean inBackground, final Callback statusCallback) {
|
||||
this.manager.registerPlugin(this, pluginId, inBackground, statusCallback);
|
||||
mManager.registerPlugin(this, pluginId, inBackground, statusCallback);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void send(String pluginId, String method, String data) {
|
||||
this.manager.send(pluginId, method, data);
|
||||
mManager.send(pluginId, method, data);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void reportErrorWithMetadata(String pluginId, String reason, String stackTrace) {
|
||||
this.manager.reportErrorWithMetadata(pluginId, reason, stackTrace);
|
||||
mManager.reportErrorWithMetadata(pluginId, reason, stackTrace);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void reportError(String pluginId, String error) {
|
||||
this.manager.reportError(pluginId, error);
|
||||
mManager.reportError(pluginId, error);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void subscribe(String pluginId, String method) {
|
||||
this.manager.subscribe(this, pluginId, method);
|
||||
mManager.subscribe(this, pluginId, method);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void respondSuccess(String responderId, String data) {
|
||||
this.manager.respondSuccess(responderId, data);
|
||||
mManager.respondSuccess(responderId, data);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void respondError(String responderId, String data) {
|
||||
this.manager.respondError(responderId, data);
|
||||
mManager.respondError(responderId, data);
|
||||
}
|
||||
|
||||
public void sendJSEvent(String eventName, WritableMap params) {
|
||||
ReactApplicationContext context = getReactApplicationContextIfActiveOrWarn();
|
||||
void sendJSEvent(String eventName, WritableMap params) {
|
||||
final ReactApplicationContext context = getReactApplicationContextIfActiveOrWarn();
|
||||
if (context != null) {
|
||||
context
|
||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,7 +21,7 @@ import java.util.List;
|
||||
public class FlipperPackage implements ReactPackage {
|
||||
@Override
|
||||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||
return Arrays.<NativeModule>asList(
|
||||
return Collections.<NativeModule>singletonList(
|
||||
new FlipperModule(FlipperReactNativeJavaScriptPluginManager.getInstance(), reactContext));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ public class FlipperReactNativeJavaScriptReceiver implements FlipperReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(FlipperObject params, FlipperResponder responder) {
|
||||
WritableMap eventData = Arguments.createMap();
|
||||
final WritableMap eventData = Arguments.createMap();
|
||||
eventData.putString("plugin", plugin);
|
||||
eventData.putString("method", method);
|
||||
eventData.putString("params", params.toJsonString());
|
||||
if (responder != null) {
|
||||
String responderId = manager.createResponderId(responder);
|
||||
final String responderId = manager.createResponderId(responder);
|
||||
eventData.putString("responderId", responderId);
|
||||
}
|
||||
module.sendJSEvent("react-native-flipper-receive-event", eventData);
|
||||
|
||||
Reference in New Issue
Block a user