mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Release React Native for Android
This is an early release and there are several things that are known not to work if you're porting your iOS app to Android. See the Known Issues guide on the website. We will work with the community to reach platform parity with iOS.
This commit is contained in:
1 parent
c372dab213
commit
42eb5464fd
571 files changed
+44550
-116
No files matched your search
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package com.facebook.react.bridge;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonFactory;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
|
||||
/**
|
||||
* Class stores configuration of javascript modules that can be used across the bridge
|
||||
*/
|
||||
public class JavaScriptModulesConfig {
|
||||
|
||||
private final List<JavaScriptModuleRegistration> mModules;
|
||||
|
||||
private JavaScriptModulesConfig(List<JavaScriptModuleRegistration> modules) {
|
||||
mModules = modules;
|
||||
}
|
||||
|
||||
/*package*/ List<JavaScriptModuleRegistration> getModuleDefinitions() {
|
||||
return mModules;
|
||||
}
|
||||
|
||||
/*package*/ String moduleDescriptions() {
|
||||
JsonFactory jsonFactory = new JsonFactory();
|
||||
StringWriter writer = new StringWriter();
|
||||
try {
|
||||
JsonGenerator jg = jsonFactory.createGenerator(writer);
|
||||
jg.writeStartObject();
|
||||
for (JavaScriptModuleRegistration registration : mModules) {
|
||||
jg.writeObjectFieldStart(registration.getName());
|
||||
appendJSModuleToJSONObject(jg, registration);
|
||||
jg.writeEndObject();
|
||||
}
|
||||
jg.writeEndObject();
|
||||
jg.close();
|
||||
} catch (IOException ioe) {
|
||||
throw new RuntimeException("Unable to serialize JavaScript module declaration", ioe);
|
||||
}
|
||||
return writer.getBuffer().toString();
|
||||
}
|
||||
|
||||
private void appendJSModuleToJSONObject(
|
||||
JsonGenerator jg,
|
||||
JavaScriptModuleRegistration registration) throws IOException {
|
||||
jg.writeObjectField("moduleID", registration.getModuleId());
|
||||
jg.writeObjectFieldStart("methods");
|
||||
for (Method method : registration.getMethods()) {
|
||||
jg.writeObjectFieldStart(method.getName());
|
||||
jg.writeObjectField("methodID", registration.getMethodId(method));
|
||||
jg.writeEndObject();
|
||||
}
|
||||
jg.writeEndObject();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private int mLastJSModuleId = 0;
|
||||
private List<JavaScriptModuleRegistration> mModules =
|
||||
new ArrayList<JavaScriptModuleRegistration>();
|
||||
|
||||
public Builder add(Class<? extends JavaScriptModule> moduleInterfaceClass) {
|
||||
int moduleId = mLastJSModuleId++;
|
||||
mModules.add(new JavaScriptModuleRegistration(moduleId, moduleInterfaceClass));
|
||||
return this;
|
||||
}
|
||||
|
||||
public JavaScriptModulesConfig build() {
|
||||
return new JavaScriptModulesConfig(mModules);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user