okaybroda / FragmentStateManager

An Android library that holds fragment states for bottom navigation view even when activity rotates.
MIT License
53 stars 15 forks source link

No working as intended - Always creates Fragments upon navigation #1

Open ajrulez opened 7 years ago

ajrulez commented 7 years ago

I was testing the sample app, and I had put breakpoints in on onCreateView, onViewCreated (and all other Fragment lifecycle methods). Much to my disappointment, all Fragments were being created every time I navigated between different Fragments using BottomNav.

I thought the very point of this library is to avoid re-creating Fragments, please correct me if I am wrong. I would appreciate any help with this (ajrulez@gmail.com)

Is it because - Fragment fragment = mFragmentManager.findFragmentByTag(tag); always returns null in method "changeFragment()". ??

okaybroda commented 7 years ago

Hi @ajrulez ,

Yes, the point of the library is to avoid recreating Fragments and to keep the view states of each fragments.

From what I've tested the fragments are only recreated when the Activity is rotated. This is unavoidable from what I've tested so far. However if you have an improvement or an idea to solve this, please send a PR.

Cheers, Viven.

ajrulez commented 6 years ago

Thanks for the comment.