This is my simple app demonstration the use of clean architecture. It gets data from the News API and entertains the user using clean architecture and MVVM.
minSdkVersion -> 23
Gradle build system
Head over to the News api above and get your own API-KEY as well.
The following diagram shows the structure of this project with 3 layers:
- Presentation
- Domain
- Data
- UI calls method from ViewModel.
- ViewModel executes Use case.
- Each Repository returns data from a Data Source (Cached or Remote).
- Information flows back to the UI where we display the list of posts.
The App is not organized into multiple modules but follows the same principles of the Presentation, Domain, and Data Layers. The presentation layer handles the UI work with the logic contained in the ViewModel. The UI uses a LiveData object from the ViewModel and observes it using the Observer Pattern. A ListAdapter handles the actual displaying of the news. Data over the network is retrieved using retrofit and coroutines to handle background work asynchronously. Additionally, note that the ViewModel uses the viewModelScope to launch the coroutines while Fragments use the viewLifeCycleOwner to observe data. The data layer uses the recommended Repository Pattern to make the network calls and store the data using Room DB.
Landing screen
Once the app is launched, the user has the option of choosing where to navigate within the app.
Search Screen
This screen is accessible from all the screens and allows the user to search for news articles.
This app will make use of the following libraries:
-
- ViewModel - Manage UI data to survive configuration changes and is lifecycle-aware
- Data Binding - Declaratively bind observable data to UI elements
- Navigation - Handle everything needed for in-app navigation
- WorkManager - Manage your Android background jobs
- Room DB - Fluent SQLite database access
- Paging - Load and display small chunks of data at a time
- LiveData - Notify views when underlying database changes
-
MockWebServer - Testing API endpoints
-
Retrofit - type safe http client with coroutines support
-
Gson - A Java serialization/deserialization library to convert Java Objects into JSON and back
-
Dagger2 - A fast dependency injector for Android and Java.
-
okhttp-logging-interceptor - logging HTTP request related data.
-
kotlinx.coroutines - Library Support for coroutines
-
Material Design - build awesome beautiful UIs.🔥🔥
-
Firebase - Backend As A Service for faster mobile development.
-
Crashylitics - Provide Realtime crash reports from users end.
-
Glide - Hassle-free image loading
-
Timber - A logger with a small, extensible API which provides utility on top of Android's normal Log class.
- As at the time this project was made, testing and UIs was not a major concern, the test coverage is not 100%
- The project is currently being maintained any. Contributions are most welcome if you would like to add more modules to the project, you can reach me through my Contacts below.
- Thanks for understanding.
Github Actions CI is used for Continuous Integration every time an update is made to the repo. The configuration is in the .develop.yml .master.yml .branch.yml*** files
This code uses Codacy for analysing the quality of the code, which is always going to be > B :)
MIT License
Copyright (c) 2019 PeteHack
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
You can reach me via my personal email pwachira900@gmail.com or my website for contibutions or reuse