Using Android Jetpack
Android Jetpack is a set of features provided by Google which helps structuring app architecture based on the MVVM Model. The benefits of the MVVM Model is that the View Model acts as an interface between the class having the data and the class using the data for displaying it. As a result the data is completely seperated from the view which ensures that the data is not lost when there are any configuration changes in the UI Screen. The main features of the Jetpack are Navigation Components, View Model and Live Data. The Navigation components help us by setting a mainactivity and then defining destinations which are fragments which have their own lifecycles and a UI Interface. The result is that the data is transferred between the destinations more efficiently and smoothly. The use of Live Data ensures that the data is automatically updated when the activity is launched and when the activity is in inactive state then no data updating events occur in the background preventing crashes. By Completely seperating the parts of a Project based on the MVVM Architecture it ensures smooth functioning of the app and provide a well organised and compatible code for all android platforms.
In the Project I first created a mainactivity with which I linked all the fragment activities which the activity will host.Then I designed all the Fragment activities Individually. I set up a View Model which acts as an interface between the Firebase Database and the activty displaying the data on the Screen.The View Model acting as an interface with an independent lifecycle of its own prevents data loss through configuration changes and it also ensures that it runs its on cycle while updating data as a result of which it automatically maintains all the asynchronus calls for modifying data on its own. The incorporation of LiveData with view model ensures that when the activity is in active state the data is automatically updated in the activity by acting as an interface between the activty and View Model. The data is transferred between fragments with the help of bundles which store data in the form of Parceable objects. In this way the seperation of various components of a project ensures maintainance and smooth functioning of apps.