architecture-components-samples icon indicating copy to clipboard operation
architecture-components-samples copied to clipboard

architecture-components-samples-NavigationAdvancedSample not work when click fast [BUG]

Open PascalTang opened this issue 6 years ago • 3 comments

Hi

I work fine in sample.

But when I click fast between tabs

onCreateView is not trigger in fragment

Will get empty view

Any solution?

PascalTang avatar Dec 05 '19 08:12 PascalTang

any answer?

PascalTang avatar Dec 30 '19 07:12 PascalTang

@saharshpruthi 这样解决是存在问题的 我解决了这个问题,我仅仅是修改了切换动画的调用时机 i.e Modify fragmentManager.beginTransaction() .setCustomAnimations( R.anim.nav_default_enter_anim, R.anim.nav_default_exit_anim, R.anim.nav_default_pop_enter_anim, R.anim.nav_default_pop_exit_anim) .attach(selectedFragment) .setPrimaryNavigationFragment(selectedFragment) .apply { // Detach all other Fragments graphIdToTagMap.forEach { _, fragmentTagIter -> if (fragmentTagIter != newlySelectedItemTag) { detach(fragmentManager.findFragmentByTag(firstFragmentTag)!!) } } } .addToBackStack(firstFragmentTag) .setReorderingAllowed(true) .commit() to fragmentManager.beginTransaction() .attach(selectedFragment) .setPrimaryNavigationFragment(selectedFragment) .apply { // Detach all other Fragments graphIdToTagMap.forEach { _, fragmentTagIter -> if (fragmentTagIter != newlySelectedItemTag) { detach(fragmentManager.findFragmentByTag(firstFragmentTag)!!) } } } .addToBackStack(firstFragmentTag) .setCustomAnimations( R.anim.nav_default_enter_anim, R.anim.nav_default_exit_anim, R.anim.nav_default_pop_enter_anim, R.anim.nav_default_pop_exit_anim) .setReorderingAllowed(true) .commit() 快速切换空白的问题已经完美解决

RDSunhy avatar Jan 08 '20 03:01 RDSunhy

You could've just said: move setCustomAnimations call after addToBackStack

ildar2 avatar Nov 12 '20 05:11 ildar2