Given: : š®
Our sample is broken.
It through a IllegalStateException: view subscriptions can't be handled when there is no view.
This cames from RxTiPresenterSubscriptionHandler.manageViewSubscription which is called from the HelloWorldPresenter#onAttachView(view)
But: Why it says that there isn't any view, when onAttachView is called? š¤
Reson: ā
After a quick reseach the reason is simple:
We introduced such a exception with #58 .
So this is working like expected.
But: Why is is thrown on onAttachView?
Because of the TiLifecycleObserver. The documentation says:
/**
gets called when the {@link net.grandcentrix.thirtyinch.TiPresenter.State} changes
@param state the new state of the {@link TiPresenter}
@param beforeLifecycleEvent {@code true} when called before the {@code on...} lifecycle
methods, {@code false} when called after
*/
beforeLifecycleEvent is wrong here.
If we take a look into the implementation in TiPresenter#attachView we see the following:
moveToState(State.VIEW_ATTACHED, false);
// Stuff
onAttachView(view);
// More stuff
moveToState(State.VIEW_ATTACHED, true);
The second parameter here indicates if the on* method is already called.
Which is wrong according to the documentation of the TiLifecycleObserver.
The fix: š
Because we have already implementations with the TiLifecycleObserver I've just changed the documentation (and a better boolean name š)
I've also fixed the implementation of the RxTiPresenter*Handler.. which have thrown the exception...
Given: : š® Our sample is broken. It through a
IllegalStateException: view subscriptions can't be handled when there is no view
. This cames fromRxTiPresenterSubscriptionHandler.manageViewSubscription
which is called from theHelloWorldPresenter#onAttachView(view)
But: Why it says that there isn't any view, when onAttachView is called? š¤
Reson: ā After a quick reseach the reason is simple: We introduced such a exception with #58 . So this is working like expected. But: Why is is thrown on
onAttachView
? Because of theTiLifecycleObserver
. The documentation says:beforeLifecycleEvent
is wrong here. If we take a look into the implementation inTiPresenter#attachView
we see the following:The second parameter here indicates if the
on*
method is already called. Which is wrong according to the documentation of theTiLifecycleObserver
.The fix: š Because we have already implementations with the
TiLifecycleObserver
I've just changed the documentation (and a better boolean name š)I've also fixed the implementation of the
RxTiPresenter*Handler
.. which have thrown the exception...