Skip to content

Commit

Permalink
convert CoreModulesPackage to use @ReactModuleList
Browse files Browse the repository at this point in the history
Reviewed By: astreet

Differential Revision: D3809512

fbshipit-source-id: 658284c642d55cf5f90e16901fdf6d4229d6b762
  • Loading branch information
aaronechiu authored and Facebook Github Bot 6 committed Sep 3, 2016
1 parent 31c8e20 commit 367c712
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 10 deletions.
2 changes: 2 additions & 0 deletions ReactAndroid/src/main/java/com/facebook/react/BUCK
Expand Up @@ -5,6 +5,8 @@ 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/module/annotations:annotations'),
react_native_target('java/com/facebook/react/module/model:model'),
react_native_target('java/com/facebook/react/modules/core:core'),
react_native_target('java/com/facebook/react/modules/debug:debug'),
react_native_target('java/com/facebook/react/modules/systeminfo:systeminfo'),
Expand Down
Expand Up @@ -13,6 +13,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import com.facebook.react.bridge.JavaScriptModule;
Expand All @@ -23,6 +24,7 @@
import com.facebook.react.devsupport.HMRClient;
import com.facebook.react.devsupport.JSCHeapCapture;
import com.facebook.react.devsupport.JSCSamplingProfiler;
import com.facebook.react.module.annotations.ReactModuleList;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.modules.core.ExceptionsManagerModule;
Expand All @@ -45,6 +47,18 @@
* require special integration with other framework parts (e.g. with the list of packages to load
* view managers from).
*/
@ReactModuleList({
AnimationsDebugModule.class,
AndroidInfoModule.class,
DeviceEventManagerModule.class,
ExceptionsManagerModule.class,
Timing.class,
SourceCodeModule.class,
UIManagerModule.class,
DebugComponentOwnershipModule.class,
JSCHeapCapture.class,
JSCSamplingProfiler.class,
})
/* package */ class CoreModulesPackage extends LazyReactPackage {

private final ReactInstanceManager mReactInstanceManager;
Expand All @@ -62,7 +76,7 @@

@Override
public List<ModuleSpec> getNativeModules(final ReactApplicationContext reactContext) {
List<ModuleSpec> moduleSpecList = new ArrayList();
List<ModuleSpec> moduleSpecList = new ArrayList<>();
moduleSpecList.add(
new ModuleSpec(AnimationsDebugModule.class, new Provider<NativeModule>() {
@Override
Expand Down Expand Up @@ -164,7 +178,7 @@ public List<Class<? extends JavaScriptModule>> createJSModules() {

@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return new ArrayList<>(0);
return Collections.emptyList();
}

private UIManagerModule createUIManager(ReactApplicationContext reactContext) {
Expand Down
Expand Up @@ -15,6 +15,7 @@ android_library(
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common/network:network'),
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/debug:debug'),
react_native_target('java/com/facebook/react/modules/systeminfo:systeminfo'),
react_native_target('res:devsupport'),
Expand Down
Expand Up @@ -20,7 +20,9 @@
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;

@ReactModule(name = "JSCHeapCapture")
public class JSCHeapCapture extends ReactContextBaseJavaModule {
public interface HeapCapture extends JavaScriptModule {
void captureHeap(String path);
Expand Down
Expand Up @@ -11,7 +11,6 @@

import javax.annotation.Nullable;

import java.io.File;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -20,7 +19,9 @@
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;

@ReactModule(name = "JSCSamplingProfiler")
public class JSCSamplingProfiler extends ReactContextBaseJavaModule {
public interface SamplingProfiler extends JavaScriptModule {
void poke(int token);
Expand Down
Expand Up @@ -139,7 +139,8 @@ private CodeBlock getCodeBlockForReactModuleInfos(List<String> nativeModules)
TypeElement typeElement = mElements.getTypeElement(nativeModule);
ReactModule reactModule = typeElement.getAnnotation(ReactModule.class);
if (reactModule == null) {
throw new ReactModuleSpecException(keyString + " not found.");
throw new ReactModuleSpecException(keyString + " not found by ReactModuleSpecProcessor. " +
"Did you forget to add the @ReactModule annotation the the native module?");
}
String valueString = new StringBuilder()
.append("new ReactModuleInfo(")
Expand Down
Expand Up @@ -18,6 +18,7 @@ android_library(
react_native_target('java/com/facebook/react/animation:animation'),
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/i18nmanager:i18nmanager'),
react_native_target('java/com/facebook/react/touch:touch'),
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),
Expand Down
Expand Up @@ -27,6 +27,7 @@
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.systrace.Systrace;
Expand All @@ -37,12 +38,12 @@
*
* <p>
* <h2>== Transactional Requirement ==</h2>
* A requirement of this class is to make sure that transactional UI updates occur all at once, meaning
* that no intermediate state is ever rendered to the screen. For example, if a JS application
* update changes the background of View A to blue and the width of View B to 100, both need to
* appear at once. Practically, this means that all UI update code related to a single transaction
* must be executed as a single code block on the UI thread. Executing as multiple code blocks
* could allow the platform UI system to interrupt and render a partial UI state.
* A requirement of this class is to make sure that transactional UI updates occur all at once,
* meaning that no intermediate state is ever rendered to the screen. For example, if a JS
* application update changes the background of View A to blue and the width of View B to 100, both
* need to appear at once. Practically, this means that all UI update code related to a single
* transaction must be executed as a single code block on the UI thread. Executing as multiple code
* blocks could allow the platform UI system to interrupt and render a partial UI state.
* </p>
*
* <p>To facilitate this, this module enqueues operations that are then applied to native view
Expand All @@ -61,6 +62,7 @@
* consider implementing a pool
* TODO(5483063): Don't dispatch the view hierarchy at the end of a batch if no UI changes occurred
*/
@ReactModule(name = "RKUIManager")
public class UIManagerModule extends ReactContextBaseJavaModule implements
OnBatchCompleteListener, LifecycleEventListener, PerformanceCounter {

Expand Down
Expand Up @@ -20,12 +20,14 @@
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;

/**
* Native module that can asynchronously request the owners hierarchy of a react tag.
*
* Example returned owner hierarchy: ['RootView', 'Dialog', 'TitleView', 'Text']
*/
@ReactModule(name = "DebugComponentOwnershipModule")
public class DebugComponentOwnershipModule extends ReactContextBaseJavaModule {

public interface RCTDebugComponentOwnership extends JavaScriptModule {
Expand Down

0 comments on commit 367c712

Please sign in to comment.