krystal00w / CS465

0 stars 0 forks source link

Inner fragment breaks navigation bar #1

Open tbarkaev opened 5 years ago

tbarkaev commented 5 years ago

Failure: If one of the original 3 fragments creates a new fragment and replaces itself with it, bottom navigation bar will not do anything until you back out to the original fragment. To reproduce: 1) Pull code from branch 'Timur'. 2) Build and run the app. 3) Go to "Discover" tab. 4) Click on "Legends", observe the bar preview screen. 5) Click on "Order" or "Tab", observe that the displayed screen does not change. 6) Click on "Back", observe the screen changing to the correct version of the chosen tab. Presumed fault: Main activity does not keep track of the active fragment if the fragment was called outside of the main activity. Attempted solution (commented out on timur branch): Add a setter for the active variable of MainActivity (lines 86-88), call it when creating the new fragment (BarPreviewFragment.java line 27). Resulting behavior: The fragment is erased, but a new fragment still is not displayed. To reproduce: 1) Uncomment the aforementioned lines. 2) Build and run the app. 3) Go to "Discover" tab. 4) Click on "Legends", observe the bar preview screen. 5) Click on "Order" or "Tab", observe that the screen is now blank, even if you then go to "Discover" tab. 6) Click on "Back", observe the screen changing to the correct version of the chosen tab.

This might be useful: https://stackoverflow.com/questions/42781409/restoring-fragment-state-when-changing-fragments-through-bottom-navigation-bar https://stackoverflow.com/questions/45611300/separate-back-stack-for-each-tab-in-bottomnavigationview-android-using-fragments https://medium.com/@smihajlovskih/create-instagram-like-backstack-4711600c5bff

tbarkaev commented 5 years ago

Update: as of right now, the master branch supports the screen resetting from inside the internal fragment, but 1) The action bar does not change 2) The fragment history is not preserved (ie it kicks you out to the original fragment of the tab, not the internal one that was active)