-
Notifications
You must be signed in to change notification settings - Fork 551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open saved state for events #1078
Comments
@liveHarshit can you please elaborate this a bit more? |
While navigation to other section (using bottom navigation) from events fragment, after returning back, events are loading again. It should not happen. |
Can I work on this? |
Please, go ahead. |
Ok. Thank you :) |
@AnEnigmaticBug Please take this up on priority |
I need to discuss what caching strategy should I use for this. I've the following strategies in mind:
|
I'll begin working on this ASAP once I get to know which one of these strategies is preferred by you. |
@AnEnigmaticBug What if we load fragment from the back stack? |
@liveHarshit that came to my mind too. But I've a (possibly misplaced) concern regarding that solution. If we solve this problem using back stack:
|
@iamareebjamal which caching strategy do you prefer? |
I don't think that there needs to be such a contrived strategy for this simple task, bottom nav view should have several fragments open simultaneously When navigating across the nav view, the fragments should remain in memory and not be replaced, and hence, onCreateView should not be called on each navigation This is a standard behaviour of bottom nav view naive implementation without any hacks or tricks |
@iamareebjamal The documentation suggests that the default behavior is to pop the back stack till the start destination and then navigate to the destination with This means that while we can solve the issue for |
Not good then. Can you think of an alternative way we can retain the standard behaviour? |
Just to avoid any confusion, can you tell me what you mean by standard behavior? |
|
IMO there are 3 issues with keeping them in memory:
|
All these problems are much deeper and separate issues. The current problem is just this -> all fragments in the bottom nav should not be replaced, recreated or removed on navigation. Just as they remain in a normal bottom nav view. Login and Profile are different. But other fragments should behave un-weirdly |
About first point, yes all the fragments in bottom nav will be in flat hierarchy, meaning they are expected by the user to be in memory all times, so it's no problem that they will keep using memory For reference to what I want, please take a look at Twitter bottom navigation |
I see. Please correct me if I'm wrong, what I think is that you want multiple back-stacks: one back-stack for each tab. Implementing this will be difficult. Ian Lake(one of the creators of the navigation component), himself said that he could only try to implement it in the navigation component in future. If we go that route, then we'll have to write a lot of custom code. IMHO trying to go that route will be a significant effort. Even material design guidelines recommend that switching between tabs should reset the screens. So a normal bottom navigation view doesn't have multiple back-stacks. This behaviour is only for Android and not for iOS supposedly because of the difficulty in implementing a complete and bug-free solution in Android. My guess is that the Twitter android app is not using the navigation component but rather are using either a different library or their own system. |
They're not using any library. The behaviour I am mentioning happens by default. If you want, I can create a sample APK with this behaviour with custom multi back stack handling logic using only appcompat and nothing else |
I agree with that. Hare problem is with navigation architecture component. It loads fragment from the back stack when we navigate to some fragment with navController and go back. But here the case is different. For bottom navigation, we set up the navigation menu with the navController and start destination is event fragment. So, no fragment goes into back stack if we navigate using the bottom nav menu then event fragment is set by default on back pressed. |
I get your point. I'm thinking of going with the StackOverflow answer given here. What do you say about this approach @iamareebjamal @liveHarshit? |
Try it if works fine. |
Here's Google's sample on Advanced usage of the Nav AAC: https://github.com/googlesamples/android-architecture-components/tree/master/NavigationAdvancedSample Maybe this can help you. They created this sample to show how to maintain multiple backstacks
|
I was also looking at the sample. This seems the way to go. Thanks for your help @haroldadmin :) |
@iamareebjamal @liveHarshit. I've not been able to work on this issue because my mid-semester exams are going on right now. They'll be over in a few days. I'll begin working on this issue the day I get free. |
Take your time. :) |
My exams are now over. I've resumed working on this issue. |
Hello. Is this issue still open? |
Describe the feature you'd like
Open saved state for events while navigating using navigation drawer.
Would you like to work on the issue?
Parent Issue: #1139
The text was updated successfully, but these errors were encountered: