fix(android): updateEventListener for root node

This commit is contained in:
maxli
2022-06-22 15:35:35 +08:00
committed by siguangli
parent 84fc2058bf
commit 572bf52a0b
2 changed files with 6 additions and 8 deletions
@@ -50,11 +50,8 @@ public class RenderNode {
protected final int mRootId;
@NonNull
protected final String mClassName;
@NonNull
protected final List<RenderNode> mChildren = new ArrayList<>();
@NonNull
protected final List<RenderNode> mChildrenUnattached = new ArrayList<>();
@NonNull
protected final ControllerManager mControllerManager;
@Nullable
protected Map<String, Object> mProps;
@@ -67,23 +67,24 @@ public class RenderRootNode extends RenderNode {
mVirtualNodes.delete(id);
}
public void updateEventListener(int rootId, @NonNull Map<String, Object> newEvents) {
@Override
public void updateEventListener(@NonNull Map<String, Object> newEvents) {
for (Entry<String, Object> entry : newEvents.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key != null && value instanceof Boolean) {
handleRootEvent(rootId, key, (Boolean) value);
handleRootEvent(key, (Boolean) value);
}
}
mEvents = newEvents;
}
private void handleRootEvent(int rootId, @NonNull String event, boolean enable) {
private void handleRootEvent(@NonNull String event, boolean enable) {
if (event.equals(ChoreographerUtils.DO_FRAME.toLowerCase())) {
if (enable) {
ChoreographerUtils.registerDoFrameListener(mRendererId, rootId);
ChoreographerUtils.registerDoFrameListener(mRendererId, getId());
} else {
ChoreographerUtils.unregisterDoFrameListener(mRendererId, rootId);
ChoreographerUtils.unregisterDoFrameListener(mRendererId, getId());
}
}
}