You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.
To be clear, you are calling getPresenter().onSubmit(getIntent()); and the implementation of #onSubmit(Intent) calls TiPresenter#getView(). TiPresenter#getView() is null and causes the NPE.
If so, everything is correct. TiPresenter#getView() is null until TiPresenter#onWakeUp() has been called (which will be called internally after Activity#onStart()).
I assume #onSubmit(Intent) is in TiActivity#onCreate() for testing and should normally be triggered from a Button. This will work, because the Button can only be clicked when the view is visible to the user. At that point, TiPresenter#onWakeUp() already got called and TiPresenter#getView() will not be null anymore.
When you really want to call the TiPresenter in TiActivity#onCreate() you have to make sure you don't trigger the view when it is not attached. Instead cache data in you Presenter and wait until the view is attached.
You are using if (savedInstanceState == null) which indicates you want some kind of initialization when the activity is initialized for the first time. Why aren't you moving that logic into TiPresenter#onCreate()?
You can pass the Intent into the constructor of your Presenter in TiActivity#providePresenter().
seems pretty legit to actually pass the intent to the presenter constructor. i got no idea why wouldn't i thought of it. Thank you for the explanation and your answer.
as per the title, calling getPresenter() on Activity onCreate causes this crash for example
any idea why would this happen? why wouldn't the view being initialised
onCreate
?The text was updated successfully, but these errors were encountered: