Aug 22, 2017 · 1 min read
Accent was on Dagger 2.11 . With this setup it will not work. As I said, it is the simplest MVP.
To preserve Presenter I would apply some changes:
- There is no need to bind and inject view instance
- I would make two new methods in presenter: connectView(View view) and disconnectView(View view) that would be called in onResume and onDestroy methods.
- disconnectView(View view) should set view to be null
- In Presenter, we should always check if view instance is null before calling any method on it. For example we should do:
if(view != null){
view.showNewText("Presenter is injected and subscribed");
}I hope that is the answer on your question. If you have more questions, please don’t hesitate to write :)
