This project is a structured template for an Android app that can be used as a starting point to create your own apps.
If you want to start an Android project with a clean architecture, reactive programming integration with Coroutines, Room database usage, Retrofit integration, Locale changer and other basic concepts used in any Android application, this code is what you need.
To prove the mentioned concepts, the full-screen Base-Android-Template application contains a BotttomNavigationView with two sections:
- Github Users is an interactive screen animated using the MotionLayout component. This screen displays a list of Github users fetched from the local Room database. If database does not contain users, the list will be retrieved from the server and then saved in Room.
- Settings is the screen where you can switch languages between Romanian and English. Here you can understand how simple and intuitive the Android Locale configurations can be.
The main goal of this application is to avoid writing basic app boilerplate code, so the base classes for Fragment and ViewModel are already implemented:
- BaseFragment - receives the corresponding ViewDataBinding and ViewModel generic types and the id of the layout to be inflated. It avoids the boilerplate code because:
- inflates the corresponding layout using DataBinding;
- set the layout databinding variables;
- observes navigation commands from ViewModel and perform navigation;
- observes loading commands and shows/hides the loading progress bar;
- observes the messages and displays them in a Toast.
- BaseViewModel - contains public methods that can be called from all ViewModels in the hierarchy to send commands to the BaseFragment to:
- navigate between fragments via Navigation component;
- display messages;
- show/hide loading progress bar.
Dependency Injection is used on the app basically to make the components decoupled and reusable and to make testing easier. The library used to achieve that is Koin
To facilitate the communication between the clean architecture layers, reactive programming is applied using Coroutines.
- DataBinding - allows to bind UI components in the layouts to data sources using a declarative format
- Navigation Component - helps implement navigation, from simple button clicks to more complex patterns, such as app bars and the navigation drawer
- Room - provides an abstraction layer over SQLite to allow fluent database access
- Coroutine - help to manage long-running tasks that might otherwise block the main thread and cause the app to become unresponsive
- Calligraphy - used to set fonts on different text views in the app
- Hawk - is a secure and simple key-value storage for Android
- Koin - brings easy dependency injection to Android
- Retrofit - a type-safe HTTP client for Android.