Giter Club home page Giter Club logo

newsster's Introduction

Newsster

Newsster is a demo application that uses MVVM pattern and Android Jetpack: the Pagging 3 library with a backend API, Saved State module for ViewModel, LiveData, ViewBinding, Room, Dagger-Hilt and Navigations Components. The app fetches data from the network with use of Retrofit integrating persisted data in the database via repository pattern. The app also uses and Kotlin Coroutines + Flow. Newsster provides translated text for the other languages, support for a landscape orientation and a night mode.

Tech stack & Open-source libraries

Jetpack components:

  • Paging 3 sets up a Repository that will use the local database to page in data for the UI and also back-fill the database from the network as the user reaches to the end of the data in the database.
  • Room Persistence - Access app's SQLite database with in-app objects and compile-time checks.
  • ViewBinding - allows to more easily write code that interacts with views and replaces findViewById.
  • ViewModel - UI related data holder, lifecycle aware.
  • Saved State module for ViewModel data that survives background process restart.
  • Lifecycles - Create a UI that automatically responds to lifecycle events.
  • LiveData - Build data objects that notify views when the underlying database changes.
  • SafeArgs for navigating and passing data between fragments.
  • Navigation - Handle everything needed for in-app navigation.
  • Room - Access app's SQLite database with in-app objects and compile-time checks.
  • Dagger-Hilt for dependency injection. Object creation and scoping is handled by Hilt.

Third party:

  • Glide for image loading.
  • Kotlin Coroutines + Flow for managing background threads with simplified code and reducing needs for callbacks
  • Retrofit2 & OkHttp3 - to make REST requests to the web service integrated.
  • Moshi to handle the deserialization of the returned JSON to Kotlin data objects.
  • Timber for logs.

Architecture:

  • MVVM Architecture
  • Repository pattern

Testing

Device Tests:

  • App Navigation Test - Navigation between screens is tested using Espresso UI framework and ActivityScenario for lifecycle state. Hilt provides test version of Repository and automatically generates a new set of components for each test. This is done with use of a CustomTestRunner that uses an Application configured with Hilt. In order to make Espresso aware of network operations UriIdlingResource is registered for UI test.
  • Database Testing - The project creates an in memory database for each database test but still runs them on the device.

Local Unit Tests:

  • Webservice Tests - The project uses MockWebServer project to test REST api interactions.
  • ViewModel Tests - ViewModels are tested using local unit tests with mock Repository implementations.
  • Repository Tests - Repository is tested using local unit tests with mock versions of Service and Database.

Design

  • Newsster is built with Material Components for Android.
  • The app starts with an asymmetric staggered list of news displayed in the RecyclerView widget. The screen also consists of options menu with category item as an icon in the app bar and setting item that appears in the overflow menu and lets the user switch themes and language. The screen takes the user to the article details with a beautiful collapsing layout.
  • The app has dialogs, buttons, menu and progress indicator customized for colors, shapes and typography. All clickable components behave intuitively changing their appearance when they are pressed.
  • The app has beautiful colors schemes for day and night modes.

Features

  • Translation for other languages.
  • Picking categories.
  • Opening an article's web site,
  • Sharing and article link,
  • Supporting landscape mode.

Preview

Open API

Newsster uses the NewsApi for constructing RESTful API. Obtain your free API_KEY NewsApi and paste it to the Constants file to try the app.

License

License

Copyright 2020 Ersiver

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

newsster's People

Contributors

ersiver avatar georgcantor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.