Search code examples
androiddesign-patternsandroid-mvp

Should Presenter handle all events of View in MVP design architecture in Android?


Suppose I have a Button in my Activity which shows me a Toast message when it is clicked. Now my question is, should I notify the Presenter when my button is clicked and the Presenter should decide what the View should do or it is not required to notify the Presenter and my View can itself show a message?


Solution

  • Even though the presenter isn't (currently) supposed to provide any data from the model to be shown in Toast upon a button click, it is still a good approach to notify the presenter by the following reasons:

    • the view and presenter behaviour might be tested (instrumentation and unit);
    • you might want to provide data from the model to be shown in Toast in the future. Such a modification would require less effort.