fix DoricPanelFragment back to recreate view,recreate context error

This commit is contained in:
pengfei.zhou 2019-12-23 19:29:19 +08:00 committed by osborn
parent 59eaf42b00
commit b88e3605b0
2 changed files with 40 additions and 32 deletions

View File

@ -62,7 +62,7 @@ public class DoricPanel extends FrameLayout implements LifecycleObserver {
public void config(DoricContext doricContext) {
mDoricContext = doricContext;
mDoricContext.getRootNode().setRootView(this);
if (getMeasuredState() != 0) {
if (getMeasuredWidth() != 0 && getMeasuredHeight() != 0) {
mDoricContext.init(DoricUtils.px2dp(getMeasuredWidth()), DoricUtils.px2dp(getMeasuredHeight()));
}
if (getContext() instanceof LifecycleOwner

View File

@ -49,6 +49,7 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (doricPanel == null) {
doricPanel = view.findViewById(R.id.doric_panel);
Bundle argument = getArguments();
if (argument == null) {
@ -83,6 +84,13 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
}
});
} else {
DoricPanel panel = view.findViewById(R.id.doric_panel);
if (doricPanel != view.findViewById(R.id.doric_panel)) {
DoricContext context = doricPanel.getDoricContext();
panel.config(context);
}
}
}
@Override