Closed dawidhyzy closed 7 years ago
The corresponding Activity|Fragment|ViewGroup Delegate takes such a boolean flag as constructor parameter.
So you have to override this method getMvpDelegate()
(always return same delegate instance, don't create a new on each getMvpDelegate() call)
I ended up doing this override, but the reasoning wasn't configuration changes.
My scenario is I have a container-like activity with a fragment that takes up this whole activity. Inside this fragment I have unrelated views and a FragmentStatePagerAdapter. This FragmentStatePagerAdapter obviously contains fragments and inside these view pager fragments I have a MviLinearLayout. When switching the adapter around, the fragments get destroyed, the views inside the fragment get destroyed, but the presenter is retained because its default behavior is to rely on the activity's state.
Any suggestions on the path forward? The way I see it, I can just say I don't care about retaining the presenter (not the end of the world) or I could have my view group delegate get a reference to my fragment and call FragmentMviDelegateImpl.retainPresenterInstance. I know you mentioned using fragment adapters a lot in your production app, so in your opinion is this a route worth going down or one I should avoid if possible?
@jhowens89 could you please open a dedicated issue (just copy & paste your comment above) for that because i haven't found any general working solution for your issue since it is not easy to find out the "parent" Fragment of MviLinearLayout
. maybe some other people here know a way to determine the "parent" fragment so that we can make the MviViewGroupDelegate lifecycle aware of the "parent" fragment.
How to not retain presenter on configuration change in Mosby 3?