android: navController check null
This commit is contained in:
parent
5113d73b37
commit
1de1fdeb47
@ -85,8 +85,11 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
|||||||
argument.putString("source", source);
|
argument.putString("source", source);
|
||||||
argument.putString("alias", alias);
|
argument.putString("alias", alias);
|
||||||
argument.putString("extra", extra);
|
argument.putString("extra", extra);
|
||||||
getNavController()
|
NavController navController = getNavController();
|
||||||
.navigate(R.id.action_doricPanelFragment_to_doricPanelFragment, argument);
|
if (navController != null) {
|
||||||
|
getNavController()
|
||||||
|
.navigate(R.id.action_doricPanelFragment_to_doricPanelFragment, argument);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,14 +98,19 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
|||||||
if (getActivity() == null || getActivity().isFinishing()) {
|
if (getActivity() == null || getActivity().isFinishing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!getNavController().popBackStack()) {
|
NavController navController = getNavController();
|
||||||
|
if (navController != null && navController.popBackStack()) {
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private NavController getNavController() {
|
private NavController getNavController() {
|
||||||
|
if (getView() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return Navigation.findNavController(getView());
|
return Navigation.findNavController(getView());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user