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.bridge.WritableMap;
|
||||||
import com.facebook.react.module.annotations.ReactModule;
|
import com.facebook.react.module.annotations.ReactModule;
|
||||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
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
|
* 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";
|
public static final String NAME = "Flipper";
|
||||||
|
|
||||||
private FlipperReactNativeJavaScriptPluginManager manager;
|
private final FlipperReactNativeJavaScriptPluginManager mManager;
|
||||||
|
|
||||||
public FlipperModule(
|
FlipperModule(
|
||||||
FlipperReactNativeJavaScriptPluginManager manager, ReactApplicationContext reactContext) {
|
FlipperReactNativeJavaScriptPluginManager manager, ReactApplicationContext reactContext) {
|
||||||
super(reactContext);
|
super(reactContext);
|
||||||
this.manager = manager;
|
mManager = manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
@@ -43,41 +45,41 @@ public class FlipperModule extends ReactContextBaseJavaModule {
|
|||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void registerPlugin(
|
public void registerPlugin(
|
||||||
final String pluginId, final Boolean inBackground, final Callback statusCallback) {
|
final String pluginId, final Boolean inBackground, final Callback statusCallback) {
|
||||||
this.manager.registerPlugin(this, pluginId, inBackground, statusCallback);
|
mManager.registerPlugin(this, pluginId, inBackground, statusCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void send(String pluginId, String method, String data) {
|
public void send(String pluginId, String method, String data) {
|
||||||
this.manager.send(pluginId, method, data);
|
mManager.send(pluginId, method, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void reportErrorWithMetadata(String pluginId, String reason, String stackTrace) {
|
public void reportErrorWithMetadata(String pluginId, String reason, String stackTrace) {
|
||||||
this.manager.reportErrorWithMetadata(pluginId, reason, stackTrace);
|
mManager.reportErrorWithMetadata(pluginId, reason, stackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void reportError(String pluginId, String error) {
|
public void reportError(String pluginId, String error) {
|
||||||
this.manager.reportError(pluginId, error);
|
mManager.reportError(pluginId, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void subscribe(String pluginId, String method) {
|
public void subscribe(String pluginId, String method) {
|
||||||
this.manager.subscribe(this, pluginId, method);
|
mManager.subscribe(this, pluginId, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void respondSuccess(String responderId, String data) {
|
public void respondSuccess(String responderId, String data) {
|
||||||
this.manager.respondSuccess(responderId, data);
|
mManager.respondSuccess(responderId, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void respondError(String responderId, String data) {
|
public void respondError(String responderId, String data) {
|
||||||
this.manager.respondError(responderId, data);
|
mManager.respondError(responderId, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendJSEvent(String eventName, WritableMap params) {
|
void sendJSEvent(String eventName, WritableMap params) {
|
||||||
ReactApplicationContext context = getReactApplicationContextIfActiveOrWarn();
|
final ReactApplicationContext context = getReactApplicationContextIfActiveOrWarn();
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
context
|
context
|
||||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.facebook.react.ReactPackage;
|
|||||||
import com.facebook.react.bridge.NativeModule;
|
import com.facebook.react.bridge.NativeModule;
|
||||||
import com.facebook.react.bridge.ReactApplicationContext;
|
import com.facebook.react.bridge.ReactApplicationContext;
|
||||||
import com.facebook.react.uimanager.ViewManager;
|
import com.facebook.react.uimanager.ViewManager;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ import java.util.List;
|
|||||||
public class FlipperPackage implements ReactPackage {
|
public class FlipperPackage implements ReactPackage {
|
||||||
@Override
|
@Override
|
||||||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||||
return Arrays.<NativeModule>asList(
|
return Collections.<NativeModule>singletonList(
|
||||||
new FlipperModule(FlipperReactNativeJavaScriptPluginManager.getInstance(), reactContext));
|
new FlipperModule(FlipperReactNativeJavaScriptPluginManager.getInstance(), reactContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ public class FlipperReactNativeJavaScriptReceiver implements FlipperReceiver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(FlipperObject params, FlipperResponder responder) {
|
public void onReceive(FlipperObject params, FlipperResponder responder) {
|
||||||
WritableMap eventData = Arguments.createMap();
|
final WritableMap eventData = Arguments.createMap();
|
||||||
eventData.putString("plugin", plugin);
|
eventData.putString("plugin", plugin);
|
||||||
eventData.putString("method", method);
|
eventData.putString("method", method);
|
||||||
eventData.putString("params", params.toJsonString());
|
eventData.putString("params", params.toJsonString());
|
||||||
if (responder != null) {
|
if (responder != null) {
|
||||||
String responderId = manager.createResponderId(responder);
|
final String responderId = manager.createResponderId(responder);
|
||||||
eventData.putString("responderId", responderId);
|
eventData.putString("responderId", responderId);
|
||||||
}
|
}
|
||||||
module.sendJSEvent("react-native-flipper-receive-event", eventData);
|
module.sendJSEvent("react-native-flipper-receive-event", eventData);
|
||||||
|
|||||||
Reference in New Issue
Block a user