This is just a sample app for news reading explaining the new Architecture Guidelines written in Kotlin. This sample app is powered by NewsAPI.
This app uses NewsAPI to get various sources and each source can provide major headlines. It uses Retrofit 2 to fetch news sources and news headlines from the API and displays in a RecyclerView. It uses Room Persistence Library to provide offline functionality App first loads the data from DB and then checks for fresh data from API, API is only called if DB data is empty or expired The main aim of this sample app is show how to use the new Architecture Guidelines with Kotlin.
- Go to NewsAPI and generate an API key (It's only 2 steps!)
- Put the API key at the bottom of the
gradle.properties
newsAPIKey = "YOUR_API_KEY"
- Run the app
The app uses ViewModel
to abstract the data from UI and Repository
as single source of truth for data. Repository
fetch the data from database and shows, while also checks if the data is old. If the data is old or database does not contain any data (such as first launch) it fetches data from Web Service and saves the data into database.
Room Persistence Library for offline support- Support for Launguage, Country and Category selection
Write test cases