Currently, Android phone is very common device and it becomes a trend of future. And restful api and Android phone is a good choice for many projects. When I worked on many projects, I got a lot of issues because I put wrong thing to wrong position on code base. After all, I create an architecture for restful Android application.
Business: Business part has two main goals:
- Managing network
- Managing datasource
- Calling api
- Uploading image
- Using ORM library
Example Client creates a new book. This action will be followed steps:
- Controller calls
BookBusiness.createBook()method will do below steps:
servercreates book fail,
onCreateBookFailure()to showing error on activity.
servercreates book successfully,
BookDatasource.createBook()creates book on database, returning
book(new book variable) to controller.
Network logicoutside of
Network logicwill be isolated.
- All logic will be belonged to
Controllerwill be thin.
Controllerhas only goals:
- Binding component views (2-way binding)
- Dispatching UI actions
Controllercan be later changed to MVVM easier.