mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-02 14:54:58 +08:00
make view managers native modules
Reviewed By: achen1 Differential Revision: D3973591 fbshipit-source-id: 44886f3bf045ed64585c92eb2e291627eed86c92
This commit is contained in:
committed by
Facebook Github Bot
parent
1296cb29eb
commit
24a83fae2f
@@ -10,11 +10,13 @@
|
||||
package com.facebook.react;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.facebook.react.bridge.ModuleSpec;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import com.facebook.systrace.Systrace;
|
||||
import com.facebook.systrace.SystraceMessage;
|
||||
|
||||
@@ -48,4 +50,26 @@ public abstract class LazyReactPackage implements ReactPackage {
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param reactContext react application context that can be used to create View Managers.
|
||||
* @return list of module specs that can create the View Managers.
|
||||
*/
|
||||
public List<ModuleSpec> getViewManagers(ReactApplicationContext reactContext) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||
List<ModuleSpec> viewManagerModuleSpecs = getViewManagers(reactContext);
|
||||
if (viewManagerModuleSpecs == null || viewManagerModuleSpecs.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<ViewManager> viewManagers = new ArrayList<>();
|
||||
for (ModuleSpec moduleSpec : viewManagerModuleSpecs) {
|
||||
viewManagers.add((ViewManager) moduleSpec.getProvider().get());
|
||||
}
|
||||
return viewManagers;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user