Git Product home page Git Product logo

android-arch-news-sample's Introduction

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!)
  • Put the API key at the bottom of the gradle.properties 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.

android-arch-news-sample's People

Contributors

akshaychordiya avatar pranaypatel512 avatar

Watchers

James Cloos avatar Shivesh Karan Mehta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.