MVVM with new android architecture components(Livedata and ViewModel)
Since the last two Google I/O ,google is keep on coming up with the new android architecture components that could really help the android engineer to design a more scalable, flexible and unit testable app.We have been following MVC,MVP,MVVM since so long to incorporate these functionalities in our app, but still in these architectures we were facing issues related to adding business logic which is linked to lifecycle events or data persistence across orientation changes.Now these new android architecture components helps us to fix these issues.
I have created a android sample app that is following MVVM with Livedata and ViewModel component. Using MVVM to keep the data layer model independent of view layer model.Presenter layer which we were using in MVP/MVVP would get replaced by ViewModel layer. This could help us to keep the presenter aware about the lifecycle events and also to keep the data persists across orientation changes.We could achieve this in presenter by incorporating Livedata and ViewModel in our ViewModel layer.
This sample uses following dependencies:
a) Retrofit
+ OkHttp
to consume APIs.
b) Rx Java to handle data streams
c) Lifecycle aware presenter created using Lifecycle support libraries
We have divided the folder structure among two top level packages i.e data and view.Data layer would take care of all the db and api stuff.This layer would be responsible for providing data to the UI layer.UI layer would have views and viewmodel classes.
In our sample we have created a BaseFragment.Each new fragment of our application will be extending to this BaseFragment so that it could register itself as view to its corresponding ViewModel class.

Similarly we would have a BaseViewModel class.Role of this BaseViewModel is to enable every ViewModel class to register itself for various lifecycle events and also register/deregister observer to get the livedata event for all its different custom livedata model used in fragment.We can easily register/deregister them on different lifecycle events as per our needs.Source of all its data could be anything(database or apis).

So if we cut long story shot we have just created all these base classes to move our common functionality to one single class to avoid repetitiveness of code in each individual fragment and their respective viewmodels.
If your project is very big ,having lots of modules we could incorporate one more layer at package level i.e domain layer like we have it in Android Clean architecture. Role of this layer is to provide communication between data and view layer.
This project can be used as a boiler plate app for your next MVVM apps which adapts with Android new Architecture Components.
This sample can be found on Github repository.
So, I am definitely going to update it as it still require few improvements to make it more unit testable code. Any feedbacks or improvements highly appreciated Thanks!