Closed matbrandao closed 8 years ago
Hi, We have a way to add presenters without use annotations. you need invoke the method registerPresenter with your presenter, you need create manually, and register on your onCreate activity life cycle.
you need remove @Inject and @Presenter for you activity.
Hi @matbrandao if you are extending from RosieActivity
or RosieAppCompatActivity
and you get the error The presenter instance to be registered can't be null
is because the presenter instance has not been initialized. You need to create an instance of your presenter and then register it manually. If you want to use the @Presenter
annotation and you don't need the dependency injection feature I recommend you to not to extend from RosieAppCompatActivity
and use the PresenterLifeCycleLinker
manually. An example could be:
public abstract class MyBaseActivity extends FragmentActivity
implements RosiePresenter.View {
private PresenterLifeCycleLinker presenterLifeCycleLinker = new PresenterLifeCycleLinker();
@Presenter MyPresenter myPresenter;
@Override protected void onCreate(Bundle savedInstanceState) {
...
myPresenter = MyPresenter();
presenterLifeCycleLinker.initializeLifeCycle(this, this);
...
}
@Override protected void onResume() {
...
presenterLifeCycleLinker.updatePresenters(this);
...
}
@Override protected void onPause() {
...
presenterLifeCycleLinker.pausePresenters();
...
}
@Override protected void onDestroy() {
...
super.onDestroy();
...
}
}
You can also initialize your presenter instance inline or try to initialize it before to call super.
Is this the answer to your question?
Using registerPresenter did it for me. Thank you for the help, and great work with the library!
You are welcome :)
I am not able to link my Activity witch extends from RosieAppCompatActivity, to my Presenter.
When i try
I always get the error "The presenter instance to be registered can't be null".
How do i link my activity to its presenter without the use of Injection?