• Stars
    star
    151
  • Rank 246,057 (Top 5 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Android App using Paging3, Hilt, Coroutines, Flow, Jetpack, MVVM architecture.

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.

More Repositories

1

Gymific

Home-workout app. Demonstrates DataStore, Hilt, MVVM, DataBinding, Kotlin Flow.
Kotlin
40
star
2

WeatherChecker

Android Weather app developed in Kotlin with use of Android Architecture Components, Coroutines, Retrofit, Moshi.
Kotlin
11
star
3

MovieToWatch

Simple movie app. Demonstrates Android Architecture Components (Navigation, WorkManager, LiveData, Room, DataBinding etc.), ServiceLocator, Retrofit, MVVM and testing.
Kotlin
5
star
4

sample-paging

Playing around with Paging library.
Kotlin
4
star
5

sample-chat-app

Sample app written in Java to demonstrate how to use the Firebase platform to create a chat app on Android.
Java
3
star
6

sample-service-locator

Sample app to demonstrate use of sample locator pattern.
Kotlin
2
star
7

MyNutrition

A nutrition calculation app written in Java with use of MVVM pattern, Android Architecture Components and Retrofit.
Java
2
star
8

FilmFlop

FilmFlop is a demo movie app to browse TMDB's movies. It demonstrates use of Hilt, NetworkBoundResource, DataBinding, Room, LiveData, MVVM, Retrofit.
Kotlin
2
star
9

sample-livedata-coroutines

Playing around with LiveData backed by coroutines.
Kotlin
1
star
10

sample-hilt

Sample code to play around with Hilt.
Kotlin
1
star
11

sample-navigation

Sample app that demonstrates use of navigation library, safe args, navigation drawer, share menu, implicit intent.
Kotlin
1
star
12

sample-drawing-on-canvas

The app uses a custom view to display a line in response to user touches.
Kotlin
1
star
13

sample-dagger

Sample to play around with dagger.
Kotlin
1
star
14

sample-android-animations

Playing around with several different kinds of animations.
Kotlin
1
star
15

sample-motionlayout

Playing around with ConstraintSets and MotionLayout in android animations.
Kotlin
1
star
16

sample-coroutines-basics

Playing around with coroutines+Architecture Components, coroutines+Retrofit. Best practices for testing.
Kotlin
1
star
17

sample-testing

Sample code that demonstrates basic testing, how to set up manual dependency injection, a service locator, and how to use fakes and mocks.
Kotlin
1
star
18

sample-workmanager-images

Applying filters to images and saving the image with WorkManager
Kotlin
1
star