All Projects → rafsanahmad → Android-MVVM-News-App

rafsanahmad / Android-MVVM-News-App

Licence: other
MVVM News Application with clean code architecture & android jetpack components.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Android-MVVM-News-App

Simple-MVVM
A simple Android MVVM pattern example
Stars: ✭ 34 (-10.53%)
Mutual labels:  retrofit2, kotlin-coroutines, mvvm-android, room-persistence-library, navigation-architecture-component
Foodium
It simply loads Posts data from API and stores it in persistence storage (i.e. SQLite Database). Posts will be always loaded from local database. Remote data (from API) and Local data is always synchronized.
Stars: ✭ 1,940 (+5005.26%)
Mutual labels:  retrofit2, mvvm-android, livedata, room-persistence-library, hilt-android
Modular App Core
Core implementations for a modular Android App
Stars: ✭ 127 (+234.21%)
Mutual labels:  clean-architecture, retrofit2, kotlin-coroutines, architecture-components, room-persistence-library
Githubprojectbrowser
This is a sample Android Project that is based on Clean Architecture
Stars: ✭ 64 (+68.42%)
Mutual labels:  clean-architecture, mockito, retrofit2, livedata, architecture-components
Clean-MVVM-NewsApp
Android News app developed using Clean + MVVM architecture
Stars: ✭ 52 (+36.84%)
Mutual labels:  clean-architecture, retrofit2, livedata, room-persistence-library
Fountain
Android Kotlin paged endpoints made easy
Stars: ✭ 175 (+360.53%)
Mutual labels:  retrofit2, livedata, architecture-components, room-persistence-library
movies
An example approach for modularization, reactive clean architecture and persistancy.
Stars: ✭ 110 (+189.47%)
Mutual labels:  clean-architecture, retrofit2, livedata, architecture-components
News Sample App
A sample news app which demonstrates clean architecture and best practices for developing android app
Stars: ✭ 334 (+778.95%)
Mutual labels:  clean-architecture, retrofit2, livedata, architecture-components
Base Mvvm
App built to showcase basic Android View components like ViewPager, RecyclerView(homogeneous and heterogeneous items), NavigationDrawer, Animated Vector Drawables, Collapsing Toolbar Layout etc. housed in a MVVM architecture
Stars: ✭ 18 (-52.63%)
Mutual labels:  retrofit2, livedata, architecture-components, room-persistence-library
FootballNews2
Personal Android project for Football daily updates
Stars: ✭ 16 (-57.89%)
Mutual labels:  clean-architecture, retrofit2, kotlin-coroutines, mvvm-android
Android-Starter-Kit
This is up-to-date android studio project for native android application, that is using modern tools and libraries.
Stars: ✭ 16 (-57.89%)
Mutual labels:  clean-architecture, mockito, robolectric, retrofit2
Posts Mvvm Daggerhilt Dynamic Feature Rxjava3 Flow Sample
Posts Api sample with Kotlin RxJava3/Coroutines Flow, Clean Architecture, Offline first/last with Room + Retrofit2, Dagger Hilt, Dynamic Feature Modules, Static Code Analysis, Gradle DSL, MockK+ MockWebServer with Test Driven Development including Api and Database tests
Stars: ✭ 41 (+7.89%)
Mutual labels:  clean-architecture, retrofit2, kotlin-coroutines, room-persistence-library
Star Wars Shop
Simple project with clean architecture and android lifecycle
Stars: ✭ 37 (-2.63%)
Mutual labels:  clean-architecture, mockito, retrofit2, architecture-components
Tdcapp
Sample app which access the TDC (The Developer's Conference) REST API.
Stars: ✭ 55 (+44.74%)
Mutual labels:  clean-architecture, mockito, livedata, architecture-components
Instant-Weather
An Android weather application implemented using the MVVM pattern, Retrofit2, Dagger Hilt, LiveData, ViewModel, Coroutines, Room, Navigation Components, Data Binding and some other libraries from the Android Jetpack.
Stars: ✭ 677 (+1681.58%)
Mutual labels:  retrofit2, livedata, room-persistence-library, navigation-architecture-component
Food Ordering App Like Swiggy Uber Eats Mvvm And Room Database
Food ordering app using MVVM architecture patterns, Architecture Lifecycle components and Room database.
Stars: ✭ 53 (+39.47%)
Mutual labels:  retrofit2, livedata, architecture-components, room-persistence-library
Clean Mvvm Archcomponents
👽 Android app consuming Star Wars API.Built with clean architecture ,MVVM pattern, Koin , Coroutines + Flows ,Architecture Components, Data Binding , Firebase , Unit/UI Tests ,Motion Layout
Stars: ✭ 285 (+650%)
Mutual labels:  clean-architecture, robolectric, retrofit2, architecture-components
Einsen
🎯 Einsen is a prioritization app that uses Eisenhower matrix technique as workflow to prioritize a list of tasks & built to Demonstrate use of Jetpack Compose with Modern Android Architecture Components & MVVM Architecture.
Stars: ✭ 821 (+2060.53%)
Mutual labels:  kotlin-coroutines, mvvm-android, room-persistence-library, hilt-android
AndroidCleanArchitecture
Android Project with clean android architecture contain Dagger, Retrofit, Retrofit, Android archtecture components, LiveData with MVVM architecture
Stars: ✭ 22 (-42.11%)
Mutual labels:  retrofit2, mvvm-android, livedata, architecture-components
Android Architecture Components Kotlin
Clean code App with Kotlin and Android Architecture Components
Stars: ✭ 23 (-39.47%)
Mutual labels:  clean-architecture, retrofit2, livedata, room-persistence-library

Android - Clean Architecture - Kotlin

The purpose of this repo is to follow up Clean Architecture principles by bringing them to Android. The repo contains a Sample News Application which shows current news from https://newsapi.org/ API.

Clean Architecture

Clean architecture promotes separation of concerns, making the code loosely coupled. This results in a more testable and flexible code. This approach divides the project into 3 modules: presentation, data, and domain.

  • Presentation: Layer with the Android Framework, the MVVM pattern and the DI module. Depends on the domain to access the use cases and on di, to inject dependencies.
  • Domain: Layer with the business logic. Contains the use cases, in charge of calling the correct repository or data member.
  • Data: Layer with the responsibility of selecting the proper data source for the domain layer. It contains the implementations of the repositories declared in the domain layer. It may, for example, check if the data in a database is up to date, and retrieve it from service if it’s not.

Functionality

The app's functionality includes:

  1. Fetch Current News data from https://newsapi.org/ & show them in RecylerView with smooth pagination.
  2. When an item is selected from RecyclerView it will load the news article in a Webview.
  3. From Details view , a news article can be added to Favorite news - which will store the News article in the Room database.
  4. From Today's news section users can search for specific news topic & return the search results with pagination.
  5. From favorite news section users can view all their saved news articles, they can also swipe left/right to delete the article from local database.

Architecture

The app uses clean architecture with MVVM(Model View View Model) design pattern. MVVM provides better separation of concern, easier testing, lifecycle awareness, etc.

UI

The UI consists of two parts

  1. View - Activity screen, Host the navigation component fragments.

  2. Fragment - Contains two fragments:

    a) FeedFragement - Show & search for today's news. Listen for onScrollListener using EndlessRecyclerOnScrollListener for Recylcerview.

    b) FavoriteFragment - Show saved news articles.

    c) DetailsFragment - Show webview with floating action button for loading & saving news article.

Model

Model is generated from JSON data into a Kotlin data class. In addition entity class has been added for room database along with Type converter for saving/retrieving custom object data.

ViewModel

MainViewModel.kt

Used for fetching today's news, searching news & update states. Also send out the status of the network call like Loading, Success, Error using sealed class.

The ViewModel also responsible for pagination of data using page count.

Dependency Injection

The app uses Dagger-hilt as a dependency injection library.

The ApplicationModule.kt class provides Singleton reference for Retrofit, OkHttpClient, Repository etc.

Network

The network layer is composed of Repository, ApiService. NewsApi - Is an interface containing the suspend functions for retrofit API call.

NewsRepository - Holds the definition of the remote/local repository call.

Building

In-order to successfully run & test the application you will need an api key.

Go to - https://newsapi.org/ and click Get Api Key

Now Go to - app/src/main/java/utils/Constants.kt

And replace

const val API_KEY = "YOUR_API_KEY"

You can open the project in Android studio and press run. Android Studio version used to build the project: Arctic fox 2020.3.1

Gradle plugin used in the project will require Java 11.0 to run.

you can set the gradle jdk in Preferences->Build Tools->Gradle->Gradle JDK

The project uses Kotin-Dsl build scripts to maintain dependencies & plugins.

Tech Stack

  1. Android appcompat, KTX, Constraint layout, Material Support.
  2. Android View Binding
  3. Hilt for dependency injection.
  4. Retrofit for REST API communication
  5. Coroutine for Network call
  6. Lifecycle, ViewModel
  7. StateFlow
  8. Room for local database.
  9. Navigation Component for supporting navigation through the app.
  10. Glide for image loading.
  11. Swipe Refresh Layout for pull-to-refresh RecyclerView.
  12. EndlessRecyclerOnScrollListener for Recylerview Infinite Scroll.
  13. Mockito & Junit for Unit testing.
  14. Robolectric for Instrumentation testing.
  15. Truth for Assertion in testing.
  16. Espresso for UI testing.

Testing

Unit testing has been added for MainViewModel & NewsRepository.

MainViewModelTest.kt

Test the viewmodel of the app using CoroutineRule & Stateflow value.

The test cases comprise of testing different states like Loading, Success, Error with fake data for testing News Response & Search Response.

NewsRepositoryTest.kt

Test the Repository of the app using Robolectric.

The test comprises of testing the functionality of Favorite News Room Database like Insertion, Remove, Get saved news etc.

Mock Webserver is used to test the Network api response in case of successful data, empty, failed case.

Sample app

License

Copyright (c) 2021 Rafsan Ahmad

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].