fix DoricPanelFragment back to recreate view,recreate context error
This commit is contained in:
		| @@ -62,7 +62,7 @@ public class DoricPanel extends FrameLayout implements LifecycleObserver { | |||||||
|     public void config(DoricContext doricContext) { |     public void config(DoricContext doricContext) { | ||||||
|         mDoricContext = doricContext; |         mDoricContext = doricContext; | ||||||
|         mDoricContext.getRootNode().setRootView(this); |         mDoricContext.getRootNode().setRootView(this); | ||||||
|         if (getMeasuredState() != 0) { |         if (getMeasuredWidth() != 0 && getMeasuredHeight() != 0) { | ||||||
|             mDoricContext.init(DoricUtils.px2dp(getMeasuredWidth()), DoricUtils.px2dp(getMeasuredHeight())); |             mDoricContext.init(DoricUtils.px2dp(getMeasuredWidth()), DoricUtils.px2dp(getMeasuredHeight())); | ||||||
|         } |         } | ||||||
|         if (getContext() instanceof LifecycleOwner |         if (getContext() instanceof LifecycleOwner | ||||||
|   | |||||||
| @@ -49,6 +49,7 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator { | |||||||
|     @Override |     @Override | ||||||
|     public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |     public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||||||
|         super.onViewCreated(view, savedInstanceState); |         super.onViewCreated(view, savedInstanceState); | ||||||
|  |         if (doricPanel == null) { | ||||||
|             doricPanel = view.findViewById(R.id.doric_panel); |             doricPanel = view.findViewById(R.id.doric_panel); | ||||||
|             Bundle argument = getArguments(); |             Bundle argument = getArguments(); | ||||||
|             if (argument == null) { |             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 |     @Override | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user