ncapdevi / FragNav

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

Possible wrong Initial index in demo app #36

Closed codeteo closed 7 years ago

codeteo commented 7 years ago

I'm currently checking the demo app and more precisely the sample with the Bottom bar and I don't understand one thing:

I read in BottomTabsActivity's code :

mNavController =
            new FragNavController(savedInstanceState, getSupportFragmentManager(), R.id.container,this,5, INDEX_NEARBY)

where INDEX_NEARBY corresponds to the 3rd tab but when I run the app the initially selected tab is the 1st one (The one named Recents) and not the third tab.

I think there is something wrong with the doc or I'm reading it wrongly : startingIndex - The initial tab index to be used must be in range of rootFragments size

Please review it and let me know, Thanks

ncapdevi commented 7 years ago

Yup, you are correct, that's actually a bug in the sample app, but necessarily the library (although it may be a bit confusing). The library being used for the bottom bar will automatically select the first tab as the initial tab. Which means that although the library was first creating that Nearby fragment, when the view was being created for the activity, it was switching to the INDEX_RECENTS, and that tab was being selected. I've just updated the sample app to fix this issue.