Skip to content

News app built using new Android Architecture Guidelines and Kotlin

License

Notifications You must be signed in to change notification settings

ekosp/android-arch-news-sample

 
 

Repository files navigation

Android Architecture NewsApp Sample

GitHub license

During Google I/O 2017, Android Team announced guidelines for architecture of Android app. This is just sample app explaining the new Architecture Guidelines written in Kotlin, YAY!

Components Demonstrated

What's the app about?

It's an extremely simple app which uses NewsAPI to show the latest news from Google News. It uses Retrofit 2 to fetch the news from the API and save them into database using Room. The main aim of this sample app is show how to use the new Architecture Guidelines with Kotlin.

Steps to run:

  • Go to NewsAPI and generate an API key (It's only 2 steps!)
  • Create new file -> credentials.properties
  • Add the API key as shown below: NEWS_API_KEY = "YOUR_API_KEY"
  • Run the app
  • Enjoyyyyy 🎉

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 if it doesn't exist then it fetches from the webservice.

Architecture


Screenshots

NewsApp Main Page


Learn Architecture Components

Trying to learn the new Architecture Components. I have wrote a series of articles to understand Android Architecture Components. Feel free to check it out to learn more.

Extra - Caster.io Course and Podcast

Todo

  • Write article explaining the complete flow of application
  • Create fork of repo showing integration with Dagger 2
  • Write test cases; (DONE for Room - DAO and Retrofit - WebService)

Testing

The architecture components are highly testable. Following table shows how to test various parts of the app (cheatsheet for testing architecture component)

Component Test Mock
UI Espresso ViewModel
ViewModel JUnit Repository
Repository JUnit DAO and WebService
DAO Instrumented -
WebService Instrumented MockWebServer

Prerequisites

  • Android Studio 3.0
  • Android Device with USB Debugging Enabled

Built With

Contributing

Please read CONTRIBUTING.md for contributions.

Proudly 💪 made in Kotlin

License

The MIT License (MIT)

Copyright (c) 2017 Akshay Chordiya

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.

About

News app built using new Android Architecture Guidelines and Kotlin

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 90.3%
  • Java 9.7%