ncapdevi / FragNav

An Android library for managing multiple stacks of fragments
1.5k stars 220 forks source link

Why are we storing fragment instances instead of only tags? #107

Closed gauravaggarwal93 closed 6 years ago

gauravaggarwal93 commented 6 years ago

Hello, Currently, fragment instances are getting stored both in fragment manager as well as in custom fragment stack created for each tab. Why can't we just store tags for fragments in the custom stack instead of instances?

ncapdevi commented 6 years ago

Excellent question, and may end up being an unnecessary redundancy. I'll look into it ASAP (hopefully later tonight).

ncapdevi commented 6 years ago

After some further review, it seems like this is a better, more efficient way to handle this. Thanks for the idea. I've created a PR that I'll be working on to implement this. Any help or contributions would be appreciated #126

ncapdevi commented 6 years ago

One thing to consider is that by doing things this way, it's possible to modify the stack (add/remove) and then immediately try to get the stack, and the previous modification may not have happened yet. It seems like an extremely rare condition, but it something to be considered.

ncapdevi commented 6 years ago

Changed in https://github.com/ncapdevi/FragNav/releases/tag/3.0.0-RC