Closed Thomas-Vos closed 6 years ago
Hey,
I see ... This bug seems to occur if you have setRetainInstance(true)
and `new FragmentMvpViewStateDelegateImpl<>(..., keepPresenterAndViewStateOnBackstack = false)´ so you don't want to keep the presenter.
Beside that this is a bug (thanks for reporting),
what is actually the reason behind using setRetainInstance(true)
in that case? Does it work as expected with setRetainInstance(false)
?
Hello @sockeqwe, I want to keep the presenter on a configuration change, that's why I call setRetainInstance(true)
. I just tried without calling setRetainInstance(true)
; the presenter is not retained anymore on a configuration change, and I'm still having the same issue.
If I return to Fragment A (by pressing back or popping the back stack), the presenter is recreated anyway, so that's why I set keepPresenterAndViewStateOnBackstack
to false. (issue #265)
I also noticed if you remove Fragment A from the back stack (go "up"), then Fragment B/C call detachView(retainInstance=true)
. I currently have worked around this by calling detachView(false)
manually in the Fragment's onDestroy()
. Is this a bug?
Thanks for your help, Thomas
See #274. Feel free to reopen this issue if 3.1.0 (snapshot) doesn't solve this porblem.
Hi Hannes,
I'm having some issues with a
ViewPager
in the back stack.Mosby Version:
mvp-common:3.0.4
andviewstate:3.0.4
Expected behavior I have a
Fragment
called A that contains aViewPager
that contains Fragments B and C. When Fragment A is put on the back stack, the methoddetachView(retainInstance=false)
gets called. At the same time,detachView(retainInstance=false)
is supposed to be called for Fragments B and C.Actual behavior (include a stacktrace if crash) When Fragment A is put on the back stack, the following happens:
detachView(retainInstance=false)
detachView(retainInstance=true)
detachView(retainInstance=true)
As you can see, retainInstance is true for both B and C, but it should be false.
Steps to reproduce the behavior or link to a sample repository
setRetainInstance(true)
in theonCreate()
method.new FragmentMvpViewStateDelegateImpl<>(this, this, true, false);
.Thanks, Thomas