我需要访问android中的所有UiComponent NativeViews,在ios中我能够使用以下代码,但在Android上我无法获得“ViewRegistry”。
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
for (NSNumber *viewIndex in [viewRegistry allKeys]) {
if(viewIndex != reactTag){
if ([viewRegistry[viewIndex] isKindOfClass:[CDTRNJWPlayerView class]]) {
CDTRNJWPlayerView *JWPlayerView = (CDTRNJWPlayerView*) viewRegistry[viewIndex];
[JWPlayerView JWPlayerPause];
}
}
}
}];
这里我在android模块中,你可以看到我只能用resolveViewManager方法得到当前的istance,我不能像我在Obj-c中那样做
UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
uiManager.addUIBlock(new UIBlock() {
public void execute (NativeViewHierarchyManager nvhm) {
CDTRNJWPlayerComponent jwplayerComponent = (CDTRNJWPlayerComponent) nvhm.resolveView(reactTag);
CDTRNJWPlayerManager jwplayerManager = (CDTRNJWPlayerManager) nvhm.resolveViewManager(reactTag);
JWPlayerView jwplayerView = (JWPlayerView) jwplayerComponent.getChildAt(0);
jwplayerManager.pause(jwplayerView);
}
});