I've been trying to make a simple notepad app (my first app), using MVP
and dagger
.
I've understood most of the stuff but I'm a little bit lost if I have multiple behaviors. I'll explain.
My project hierarchy goes like this :
Click here
- MainActivity - The activity class, holds a listview.
- MainPresenter - interface, holding a setup container method, and a refresh one
- MainPresenterImpl - the implementation of the presenter
- MainView - interface for the MainActivity (for mvp)
- Note_Container - Contains the NoteHandler to load-save notes, creates/stores the adapter and can make changes
- Ignore noteactivity its empty
- di folder is for dependency injection
- models has only a note class that holds two strings
- NoteHandler - Contains the NoteRepository and handles exceptions whenever they're thrown.
- NoteRepository - Saves and loads the notes from a file using gson library.
After explaining all of these you should (probably) have understood how the project works (feel free to criticize the hierarchy).
Now I want to add a button that creates a note. I'll just add the listener on the mainactivity
and redirect it to the Presenter...
But will the presenter handle the code to add a new note (Start a new intent, etc) or should I make a new class that will independently just handle this stuff?
If I want to add more buttons in the future, for example remove-all-notes or launch a help dialog, should I make for each button a class that will handle the code?
How can I organize something like that?