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
Fragment might lose the presenter id #83
Comments
Do you mean, that Do you have an example? I know about a fragment bug - they sometimes do not save state while being in back stack and you need to flip screen twice. I don't know if it was fixed yet. |
I do not attach the fragment back to the screen after the orientation change. Therefore onResume is not getting called at all. I might be doing something stupid with the FragmentManager: Basically I add two fragments to a container and detach the one I do not want to show. Edit: As a workaround i am currently setting a factory which returns null in onCreate if i already have a presenter set. |
Presenter normally becomes created during the first I would use a debugger and find out what is the real reason for this. |
getPresenter() will not work without a factory, which is not set in my case. |
You need to supply a presenter factory in another way then. |
I have worked around it currently, just thougth that there is no reason not to keep the presenter id in the bundle. |
How could we connect views with presenters without saving presenter's id? |
I ment that the presenter id should not get lost. That the information is there and should not be discarded, regardless whether there is a factory set or not. |
Why did you override the default presenter factory at all? I think that the default way with just one annotation is awesome. Dagger can be used with this way as well. |
Can you link me more information to that? All i found was that gist while checking if there already was an issue like mine https://gist.github.com/konmik/6ac725fa7134402539c4. I am setting a custom factory because dagger (2) is constructing my presenter. |
Well that looks somewhat similar to what I am doing. in onActivityCreated because i need the context: and the factory:
|
You have activity right in fragment's There is also no need in activity context for presenters at all (if you don't want to have leaks). If you need Application context you can access it using singleton pattern i.e. using a static variable and a static getter function. |
Yeah, I was only using the context to get the Application context. Did not think about using a static getter, will do that, thanks. I guess this ticket is unnecessary when sticking to the rules . |
If a fragments (PresenterLifecycleDelegates) onSaveInstanceState method gets called before the PresenterFactory is set, it will not save its presenter id in the result bundle.
I have a NucleusSupportFragment for which I set the PresenterFactory in onActivityCreated.
When I detach that fragment (without destroying the presenter) and rotate the screen once, the presenter id will be saved in the bundle . After another rotate however the presenter id will not be saved anymore because getPresenter() will not restore the Presenter without a set Factory.
The text was updated successfully, but these errors were encountered: