fix DoricPanelFragment back to recreate view,recreate context error
This commit is contained in:
parent
59eaf42b00
commit
b88e3605b0
@ -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,40 +49,48 @@ 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);
|
||||||
doricPanel = view.findViewById(R.id.doric_panel);
|
if (doricPanel == null) {
|
||||||
Bundle argument = getArguments();
|
doricPanel = view.findViewById(R.id.doric_panel);
|
||||||
if (argument == null) {
|
Bundle argument = getArguments();
|
||||||
if (getActivity() != null && getActivity().getIntent() != null) {
|
if (argument == null) {
|
||||||
argument = getActivity().getIntent().getExtras();
|
if (getActivity() != null && getActivity().getIntent() != null) {
|
||||||
|
argument = getActivity().getIntent().getExtras();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (argument == null) {
|
||||||
if (argument == null) {
|
DoricLog.e("DoricPanelFragment argument is null");
|
||||||
DoricLog.e("DoricPanelFragment argument is null");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
final String alias = argument.getString("alias");
|
||||||
final String alias = argument.getString("alias");
|
String scheme = argument.getString("scheme");
|
||||||
String scheme = argument.getString("scheme");
|
final String extra = argument.getString("extra");
|
||||||
final String extra = argument.getString("extra");
|
DoricJSLoaderManager.getInstance().loadJSBundle(scheme).setCallback(new AsyncResult.Callback<String>() {
|
||||||
DoricJSLoaderManager.getInstance().loadJSBundle(scheme).setCallback(new AsyncResult.Callback<String>() {
|
@Override
|
||||||
@Override
|
public void onResult(String result) {
|
||||||
public void onResult(String result) {
|
doricPanel.config(result, alias, extra);
|
||||||
doricPanel.config(result, alias, extra);
|
DoricContext context = doricPanel.getDoricContext();
|
||||||
|
context.setDoricNavigator(DoricPanelFragment.this);
|
||||||
|
BaseDoricNavBar navBar = requireActivity().getWindow().getDecorView().findViewById(R.id.doric_nav_bar);
|
||||||
|
context.setDoricNavBar(navBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable t) {
|
||||||
|
DoricLog.e("DoricPanelFragment load JS error:" + t.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinish() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
DoricPanel panel = view.findViewById(R.id.doric_panel);
|
||||||
|
if (doricPanel != view.findViewById(R.id.doric_panel)) {
|
||||||
DoricContext context = doricPanel.getDoricContext();
|
DoricContext context = doricPanel.getDoricContext();
|
||||||
context.setDoricNavigator(DoricPanelFragment.this);
|
panel.config(context);
|
||||||
BaseDoricNavBar navBar = requireActivity().getWindow().getDecorView().findViewById(R.id.doric_nav_bar);
|
|
||||||
context.setDoricNavBar(navBar);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void onError(Throwable t) {
|
|
||||||
DoricLog.e("DoricPanelFragment load JS error:" + t.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFinish() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user