mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-30 13:22:13 +08:00
Fix detaching views rendered under header config component. (#282)
This change fixes the problem when header update would get triggered while the header config subviews are not yet fully unmounted. The root cause of this problem is kind of a mystery, I encouneter a crash when going back using back button from a screen that have custom back button image rendered. Turned out that after implementing removeAll schema the problem no longer occurs. I didn't have enough time to investigate it further but supporting removeAll schema is an improvement regardless so going with this solution for now.
This commit is contained in:
committed by
GitHub
parent
28f57240c2
commit
1ac742610b
@@ -105,6 +105,14 @@ public class ScreenContainer<T extends ScreenFragment> extends ViewGroup {
|
|||||||
markUpdated();
|
markUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void removeAllScreens() {
|
||||||
|
for (int i = 0, size = mScreenFragments.size(); i < size; i++) {
|
||||||
|
mScreenFragments.get(i).getScreen().setContainer(null);
|
||||||
|
}
|
||||||
|
mScreenFragments.clear();
|
||||||
|
markUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startViewTransition(View view) {
|
public void startViewTransition(View view) {
|
||||||
super.startViewTransition(view);
|
super.startViewTransition(view);
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ public class ScreenContainerViewManager extends ViewGroupManager<ScreenContainer
|
|||||||
parent.removeScreenAt(index);
|
parent.removeScreenAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAllViews(ScreenContainer parent) {
|
||||||
|
parent.removeAllScreens();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getChildCount(ScreenContainer parent) {
|
public int getChildCount(ScreenContainer parent) {
|
||||||
return parent.getScreenCount();
|
return parent.getScreenCount();
|
||||||
|
|||||||
@@ -97,6 +97,12 @@ public class ScreenStack extends ScreenContainer<ScreenStackFragment> {
|
|||||||
super.removeScreenAt(index);
|
super.removeScreenAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void removeAllScreens() {
|
||||||
|
mDismissed.clear();
|
||||||
|
super.removeAllScreens();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean hasScreen(ScreenFragment screenFragment) {
|
protected boolean hasScreen(ScreenFragment screenFragment) {
|
||||||
return super.hasScreen(screenFragment) && !mDismissed.contains(screenFragment);
|
return super.hasScreen(screenFragment) && !mDismissed.contains(screenFragment);
|
||||||
|
|||||||
@@ -243,6 +243,11 @@ public class ScreenStackHeaderConfig extends ViewGroup {
|
|||||||
maybeUpdate();
|
maybeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeAllConfigSubviews() {
|
||||||
|
mConfigSubviews.clear();
|
||||||
|
maybeUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
public void addConfigSubview(ScreenStackHeaderSubview child, int index) {
|
public void addConfigSubview(ScreenStackHeaderSubview child, int index) {
|
||||||
mConfigSubviews.add(index, child);
|
mConfigSubviews.add(index, child);
|
||||||
maybeUpdate();
|
maybeUpdate();
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ public class ScreenStackHeaderConfigViewManager extends ViewGroupManager<ScreenS
|
|||||||
parent.addConfigSubview((ScreenStackHeaderSubview) child, index);
|
parent.addConfigSubview((ScreenStackHeaderSubview) child, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAllViews(ScreenStackHeaderConfig parent) {
|
||||||
|
parent.removeAllConfigSubviews();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeViewAt(ScreenStackHeaderConfig parent, int index) {
|
public void removeViewAt(ScreenStackHeaderConfig parent, int index) {
|
||||||
parent.removeConfigSubview(index);
|
parent.removeConfigSubview(index);
|
||||||
|
|||||||
Reference in New Issue
Block a user