fix(android): sticky header not deleted from ControllerManager (#3356)

may crash in vue2 when recreating view with same id

Co-authored-by: siguangli <siguangli@qq.com>
Co-authored-by: OpenHippy <124017524+open-hippy@users.noreply.github.com>
This commit is contained in:
iPel
2023-07-10 03:42:20 +00:00
committed by GitHub
co-authored by siguangli OpenHippy
parent 4af21ac51f
commit 48decb1025
2 changed files with 12 additions and 10 deletions
@@ -527,7 +527,7 @@ public class ControllerManager {
@SuppressWarnings({"unchecked", "rawtypes"})
public void deleteChildRecursive(int rootId, ViewGroup parent, View child, boolean recyclable) {
if (parent == null || child == null) {
if (child == null) {
return;
}
HippyViewController childController = null;
@@ -555,15 +555,17 @@ public class ControllerManager {
}
}
}
String parentTag = NativeViewTag.getClassName(parent);
if (parentTag != null) {
HippyViewController parentController = mControllerRegistry.getViewController(
parentTag);
if (parentController != null) {
parentController.deleteChild(parent, child);
if (parent != null) {
String parentTag = NativeViewTag.getClassName(parent);
if (parentTag != null) {
HippyViewController parentController = mControllerRegistry.getViewController(
parentTag);
if (parentController != null) {
parentController.deleteChild(parent, child);
}
} else {
parent.removeView(child);
}
} else {
parent.removeView(child);
}
mControllerRegistry.removeView(rootId, child.getId());
if (checkRecyclable(childController, recyclable) && childTag != null) {
@@ -69,7 +69,7 @@ public class ListItemRenderNode extends RenderNode {
if (parentNode != null) {
mControllerManager.deleteChild(mRootId, parentNode.getId(), mId, true);
} else {
removeChildrenView(this);
mControllerManager.deleteChildRecursive(mRootId, null, getHostView(), true);
}
}