Closed epetrenko closed 7 years ago
Thanks for this super helpful bug report!
Indeed it seems like this is a bug in PresenterManager
.
I think it won't crash if you set keepPresenterInstance = true
(constructor parameter of delegate)
Indeed you have to delegate delegate.onViewDestroyed()
, so that is another bug of the demo app.
I will work on that right now, fix should be available soon.
@sockeqwe Thanks for a quick response.
You're right, there are no crashes if presenter should be kept.
Is fixed, thanks for reporting.
Fix is available in 3.0.2-SNAPSHOT
(building right now on CI, available in about 20 Minutes)
A stable 3.0.2
release to come tomorrow.
3.0.2
has been released.
Thanks again for your very detailed bug report and sample repository to reproduce the bug (it was super helpful)!
Hi there.
I think there is a possible bug in the latest Mosby release, when using custom
DialogFragment
, which has MVP structure and usesFragmentMvpDelegateImpl
. MVP dialog is shown inside activity with it's own MVP. I have created a sample repo to help reproduce this issue.Mosby Version: 3.0.0 Actual behavior: crash when closing fragment dialog with MVP Sample repository: https://github.com/epetrenko/MosbyFragmentMvpDelegateExample
There are two main parts in my sample repo:
MvpActivity
);AppCompatDialogFragment
and implementsMvpDelegateCallback
). Login dialog is shown from main screen by clicking on a button. It's done only for example.Presenters and views are dummy in my example. Dagger stuff was added only as example.
LoginDialogFragment
hasFragmentMvpDelegateImpl
:I don't need to preserve presenter neither during screen orientation nor on backstack.
MainActivity
is implemented only in portrait orientation.Lifecycle methods are overriden in
LoginDialogFragment
:Application is crashed after
onDestroyView()
call ondelegate
. I'm not sure shouldonDestroyView()
be overriden or not, because StatisticsDialog have noonDestroyView()
overriding in mail sample from Mosby repo.I checked
onDestroyView()
method implementation inFragmentMvpDelegateImpl
:Method
retainPresenterInstance()
returnsfalse
(as I noticed above I don't need to keep presenter in all cases). ThereforePresenterManager.remove(activity, mosbyViewId)
method should be fired.Inside
PresenterManager.remove(activity, viewId)
method we have the following:As
activityScope
isn'tnull
, we go intoactivityScope.remove(viewId)
. And this method throwsNullPointerException
exception, becauseviewId
isnull
.If
onDestroyView()
overriding should not be used here, then all is working properly. Hope it helps.