abhinav272 / NewsApp

A Sample News App written in Kotlin using Android Architecture Components, MVVM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Android Architecture Sample

Android Architecture Components were announced in Google I/O 2017 This is just a sample app explaining the new Architecture Guidelines written in Kotlin. This sample app is powered by NewsAPI.

Components Used

About App

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.

If you want to run:

  • 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

Architecture

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.

Architecture


Screenshots

NewsApp Main Page

NewsApp Main Page

NewsApp Main Page


Future Roadmap

  • Room Persistence Library for offline support
  • Support for Launguage, Country and Category selection
  • Write test cases

Proudly 💪 made in Kotlin

License


The MIT License (MIT)

Copyright (c) 2017 Abhinav Sharma

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.