项目中有一个书架的View提供给ReactNative使用,监听ReactNative相应的生命周期进行界面刷新,代码如下
//ViewManager
public class BookShelfManager extends SimpleViewManager<BookShelfView> {
private BookShelfView mBookShelfView;
@Override
protected BookShelfView createViewInstance(ThemedReactContext reactContext) {
mBookShelfView = new BookShelfView(reactContext.getCurrentActivity());
reactContext.addLifecycleEventListener(mBookShelfView);
mBookShelfView.setReactContext(reactContext);
return mBookShelfView;
}