KunMinX/Smooth-Navigation

代码设置NavGraph,二级页面返回后白屏

wsdydeni opened this issue · 1 comments

我在代码里面初始化navGraph

        val navHostFragment =
            supportFragmentManager.findFragmentById(R.id.nav_host_fragment_identity) as NavHostFragment
        val navController = NavHostFragment.findNavController(navHostFragment)
        navController.setGraph(
            if(authStatus == "1") R.navigation.nav_identity
            else R.navigation.nav_identity_verify
        )

设置了之后,在某个二级页面返回,白屏了

 Navigation.findNavController(requireActivity(),R.id.nav_host_fragment_identity).navigateUp()

第一次设置navGrpah的日志

2022-01-21 16:12:17.797 D/Nav: --isSingleTopReplacement --- false
2022-01-21 16:12:17.797 D/Nav: --mBackStack.size:0 getFragments().size():0
2022-01-21 16:12:17.797 D/Nav: --Replace --- InitiateVerifyFragment{6b983ed} (35176420-6950-4140-97fe-c1951b65d7a9)

跳转二级页面的日志

2022-01-21 16:12:21.625 D/Nav: --isSingleTopReplacement --- false
2022-01-21 16:12:21.625 D/Nav: --mBackStack.size:1 getFragments().size():1
2022-01-21 16:12:21.625 D/Nav: --Add --- UploadVerifyFragment{9c80c27} (b504e152-121d-4bc7-84cf-efa6358bf1ca)
2022-01-21 16:12:21.626 D/Nav: --Hide --- InitiateVerifyFragment{ddb6b77} (55ca39c0-09e1-4355-b0dc-c311cb6af423 id=0

返回的时候没有日志,只隐藏了二级页面,一级页面也没显示,导致白屏了。

去掉了xml里面的动画(自带的动画)之后,行为似乎正常了。