🍲Foodium is a sample food blog Android application 📱 built to demonstrate the use of Modern Android development tools - (Kotlin, Coroutines, Flow, Dagger 2/Hilt, Architecture Components, MVVM, Room, Retrofit, Moshi, Material Components).

Overview

Foodium 🍲  

Test Build Lint

GitHub license Android Weekly ktlint Github Followers GitHub stars GitHub forks GitHub watchers Twitter Follow

Foodium is a sample food blog 🍲 Android application 📱 built to demonstrate use of Modern Android development tools. Dedicated to all Android Developers with ❤️ .

You can Install and test latest Foodium app from below 👇

Foodium App

About

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.

  • This makes it offline capable 😃 .
  • Clean and Simple Material UI.
  • It supports dark theme too 🌗 .

Dummy API is used in this app. JSON response is statically hosted here.

Built With 🛠

  • Kotlin - First class and official programming language for Android development.
  • Coroutines - For asynchronous and more..
  • Flow - A cold asynchronous data stream that sequentially emits values and completes normally or with an exception.
  • Android Architecture Components - Collection of libraries that help you design robust, testable, and maintainable apps.
    • LiveData - Data objects that notify views when the underlying database changes.
    • ViewModel - Stores UI-related data that isn't destroyed on UI changes.
    • ViewBinding - Generates a binding class for each XML layout file present in that module and allows you to more easily write code that interacts with views.
    • Room - SQLite object mapping library.
  • Dependency Injection -
    • Hilt-Dagger - Standard library to incorporate Dagger dependency injection into an Android application.
    • Hilt-ViewModel - DI for injecting ViewModel.
  • Retrofit - A type-safe HTTP client for Android and Java.
  • Moshi - A modern JSON library for Kotlin and Java.
  • Moshi Converter - A Converter which uses Moshi for serialization to and from JSON.
  • Coil-kt - An image loading library for Android backed by Kotlin Coroutines.
  • Material Components for Android - Modular and customizable Material Design UI components for Android.
  • Gradle Kotlin DSL - For writing Gradle build scripts using Kotlin.

Lint ✅

This project uses GitHub Super Linter which is Combination of multiple linters to install as a GitHub Action.

Following Linters are used internally by super linter (enabled for this project):

Dagger (Old) DI Version 🗡️

If you want to refer old way of Dependency Injetion using Dagger2, see branch dagger2-di

Dagger2 Version

Koin DI Version 🗡️

If you want to use Koin - Dependency Injection framework in app then visit below repository.

Koin Version

Contributed By: Pranay Patel

Package Structure

dev.shreyaspatil.foodium    # Root Package
.
├── data                # For data handling.
│   ├── local           # Local Persistence Database. Room (SQLite) database
|   │   ├── dao         # Data Access Object for Room   
│   ├── remote          # Remote Data Handlers     
|   │   ├── api         # Retrofit API for remote end point.
│   └── repository      # Single source of data.
|
├── model               # Model classes
|
├── di                  # Dependency Injection             
│   ├── builder         # Activity Builder
│   ├── component       # DI Components       
│   └── module          # DI Modules
|
├── ui                  # Activity/View layer
│   ├── base            # Base View
│   ├── main            # Main Screen Activity & ViewModel
|   │   ├── adapter     # Adapter for RecyclerView
|   │   └── viewmodel   # ViewHolder for RecyclerView   
│   └── details         # Detail Screen Activity and ViewModel
|
└── utils               # Utility Classes / Kotlin extensions

Architecture

This app uses MVVM (Model View View-Model) architecture.

Contribute

If you want to contribute to this library, you're always welcome! See Contributing Guidelines.

Discuss 💬

Have any questions, doubts or want to present your opinions, views? You're always welcome. You can start discussions.

Contact

If you need any help, you can connect with me.

Visit:- shreyaspatil.dev

License

MIT License

Copyright (c) 2020 Shreyas Patil

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.
Comments
  • Added slide animation of recyclerView with MotionLayout

    Added slide animation of recyclerView with MotionLayout

    - Summary

    Impoving UI

    - Description for the changelog

    Added slide animation of recyclerView with MotionLayout

    - A picture or screenshot regarding change (not mandatory but encouraged)

    ezgif-com-video-to-gif-6.gif

    opened by GeorgCantor 9
  • Allways state is  succesfull

    Allways state is succesfull

    Due to this code state always succesfull,

    emitAll(fetchFromLocal().map {
               State.success<RESULT>(it)
           })
    

    so after internet connection is back,

         ```
    if (mViewModel.postsLiveData.value is State.Error || mAdapter.itemCount == 0) {
                        getPosts()
                    }
    

    this block of code does not work... what i can do fetch new result when immediately the connection is back,

    opened by shamshadpattani 6
  • Doubt

    Doubt

    First of all, awesome repository. Got a lot to learn in it. :smiley:

    I've a doubt in your code.

    Here, https://github.com/PatilShreyas/Foodium/blob/75e4541908c80ae2e4ec3221fb37ffc23ed5b094/app/src/main/java/dev/shreyaspatil/foodium/data/repository/NetworkBoundRepository.kt#L93-L94,

    Why did you marked fetchFromRemote with @MainThread ? Should it be called from WorkerThread? :thinking:

    opened by theapache64 5
  • Deprecated JUnit AssertThat()

    Deprecated JUnit AssertThat()

    Describe the bug/request JUnit "AssertThat" is deprecated use Google Truth instead of that.

    Additional context In FoodiumServiceTest class the JUnit assertThat is used. Please use google truth instead of this.

    opened by RAJATNEGI 4
  • Running dao tests runs forever

    Running dao tests runs forever

    While running tests for PostsDaoTest the tests keeps running without completing. But if i test with normal flow builder emitting item and asserting inside run blocking it completes and tests pass.

        val flow =  flow {
            emit(1)
        }
    
        assertThat(1, equalTo(flow.first()))
    

    The above works inside runBlocking.

    I found nothing similar to this issue on internet. Running on latest android studio. Am i missing anything

    1

    opened by raghunandankavi2010 4
  • Update share button functionality to show android share sheet

    Update share button functionality to show android share sheet

    - Summary Use the Android Sharesheet to provide the share functionality, allowing for a more modern looking share menu on Android 10 (API level 29) and above. This will also add the ability to show rich content to previews.

    - Description for the changelog Handles the share action by creating an Intent with ACTION_SEND and uses the Intent.createChooser to return a share sheet intent.

    - A picture or screenshot regarding change (not mandatory but encouraged) On Android 10,

    On Android 6,

    Closes #48

    opened by meets7 3
  • Emit Network Response directly without saving the data.

    Emit Network Response directly without saving the data.

    There will be a scenario in which we won't need to save the data to database and use values directly from the network. Can you share a similar version of NetworkBoundRepository to perform the same. Screen Shot 2020-10-28 at 7 44 08 PM

    opened by bibutikoley 3
  • Visitable Pattern RecyclerView

    Visitable Pattern RecyclerView

    Hi @PatilShreyas how about we improve the PostListAdapter with Visitable Pattern? So we can add view items more dynamically in the app and create the factory for the ViewHolders.

    And also I think setPosts function in PostListAdapter should not use notifyDataSetChanged to update the list, if we use that the DiffUtil.ItemCallback will become useless because the adapter will re-render the all items which resulted in blinking page.

    Instead we could use submitList(items) provided by ListAdapter that PostListAdapter extends to only re-render the items which data have changed with the correct animation.

    Thank you 🙏

    Ref: https://proandroiddev.com/writing-better-adapters-1b09758407d2

    opened by pandubaraja 3
  • Replace Junit AssertThat with Google Truth AssertThat

    Replace Junit AssertThat with Google Truth AssertThat

    - Summary

    Junit AssertThat is deprecated so i use Google truth instead of it.

    - Description for the changelog

    - A picture or screenshot regarding change (not mandatory but encouraged) image

    opened by RAJATNEGI 2
  • Navigating to activities using starter pattern

    Navigating to activities using starter pattern

    - Summary

    Move the activity transaction logic to the target activity using the starter pattern. This pattern really helps when we are working in collaborative projects. When a change is made, say a new extra parameter is required for an activity, this wouldn't throw a compile-time error, but our app will crash during runtime.

    With this, we can catch during compilation, and project contributors can know the required params for starting the activity.

    More information on this pattern: https://blog.mindorks.com/learn-to-write-good-code-in-android-starter-pattern

    - Description for the changelog

    Instead of starting activities by creating Intent in the calling method, we call a function which is written in the Activity to start the activity.

    Existing code:

    
      val intent = Intent(this, PostDetailsActivity::class.java)
            intent.putExtra(PostDetailsActivity.POST_ID, post.id)
    
      val options = ActivityOptionsCompat.makeSceneTransitionAnimation(
            this,
            imageView,
            imageView.transitionName
       )
    
     startActivity(intent, options.toBundle())
    

    Updated:

     val options = ActivityOptionsCompat.makeSceneTransitionAnimation(
           this,
           imageView,
           imageView.transitionName
     )
    
     PostDetailsActivity.start(this, post.id, options)
    

    - A picture or screenshot regarding change (not mandatory but encouraged)

    opened by sidhu18 2
  • Use the Android Sharesheet for a more modern looking share tray

    Use the Android Sharesheet for a more modern looking share tray

    Describe the bug/request Use the Android Sharesheet to provide the share functionality, allowing for a more modern looking share menu on Android 10 (API level 29) and above. This will also add the ability to show rich content to previews.

    So the UI for the share tray could something like this post this change:

    Additional context Essentially, the following change will be done:

    For all types of sharing, create an intent and set its action to Intent.ACTION_SEND. In order to display the Android Sharesheet you need to call Intent.createChooser() , passing it your Intent object. It returns a version of your intent that will always display the Android Sharesheet.

    Source: link

    opened by meets7 2
  • Use `distinctUntilChanged()` in DAO

    Use `distinctUntilChanged()` in DAO

    Should we not use distinctUntilChanged() in dao?.

          @Query("SELECT * FROM ${Post.TABLE_NAME} WHERE ID = :postId")
          fun getPostById(postId: Int): Flow<Post>
    
          fun getPostByIdUntilChanged(id: Int) = getPostById(id).distinctUntilChanged()
    

    cause if we update a unrelated row the query also emits data with the same result again. https://medium.com/androiddevelopers/room-flow-273acffe5b57

    Originally posted by @raghunandankavi2010 in https://github.com/PatilShreyas/Foodium/discussions/61

    opened by PatilShreyas 0
Releases(v1.1)
  • v1.1(Jan 16, 2021)

    What's new?

    • [#23] Add sharing button for sharing a post. (Thanks to @naufalprakoso)
    • [#48] Use Android share sheet for sharing the post. (Thanks to @meets7)

    Bug fixes:

    • [#37] Crashing issue on clicking a post item on devices running API level lower than 24.

    Technical improvements

    • [#38] Use Flow's catch operator (Thanks to @shubham08gupta).
    • [#41] Use Room suspending functions. (Thanks to @shubham08gupta).
    • [#43] Clear unused resources. (Thanks to @GeorgCantor).
    • [#51] Use starter pattern for navigating from MainActivity to PostDetailsActivity. (Thanks to @sidhu18).
    • Use Dagger and Hilt for dependency injection.

    Thanks to all contributors 🙇🏻‍♂️

    Source code(tar.gz)
    Source code(zip)
    app.apk(6.90 MB)
  • v1.0(Jun 19, 2020)

Owner
Shreyas Patil
👨‍🎓 IT Undergrad 📱 Mobile App Developer ❤️Android 🌎Web Developer ⚙️Open Source Enthusiast 👨‍💻Organizer @KotlinMumbai
Shreyas Patil
🗡️ Deddit demonstrates modern Android development with Hilt, Coroutines, Flow, Jetpack, and Material Design based on MVVM architecture

Deddit demonstrates modern Android development with Hilt, Coroutines, Flow, Jetpack (ViewModel,Paging3), and Material Design based on MVVM

Krish Parekh 9 Sep 2, 2022
📒 NotyKT is a complete 💎Kotlin-stack (Backend + Android) 📱 application built to demonstrate the use of Modern development tools with best practices implementation🦸.

NotyKT ??️ NotyKT is the complete Kotlin-stack note taking ??️ application ?? built to demonstrate a use of Kotlin programming language in server-side

Shreyas Patil 1.4k Dec 26, 2022
App built using Kotlin, Dagger Hilt, Room Database, Coroutines, Flow, AndroidX Glance, WorkManager, Coil etc.

An article sharing platform where you can personalize, subscribe to your favorite topics, get daily-read reminders, etc. App built using Kotlin, Dagger Hilt, Room Database, Coroutines, Flow, AndroidX Glance, WorkManager, Coil etc.

Kasem SM 484 Jan 3, 2023
🛒 Mercado Libre App Clone using modern Android development with Hilt, Coroutines, Jetpack (Room, ViewModel), and Jetpack Compose based on MVVM architecture.

Meli Clone ?? Mercado Libre App Clone using modern Android development with Hilt, Coroutines, Jetpack (Room, ViewModel), and Jetpack Compose based on

Esteban Aragon 7 Sep 22, 2022
A clean architecture example. Using Kotlin Flow, Retrofit and Dagger Hilt, etc.

android-clean-architecture A clean architecture example. Using Kotlin Flow, Retrofit and Dagger Hilt, etc. Intro Architecture means the overall design

Prieyudha Akadita S. 69 Dec 21, 2022
MVVM ,Hilt DI ,LiveData ,Flow ,SharedFlow ,Room ,Retrofit ,Coroutine , Navigation Component ,DataStore ,DataBinding , ViewBinding, Coil

RickMorty This is a simple app which has been implemented using Clean Architecture alongside MVVM design to run (online/offline) using : [ MVVM ,Hilt

Ali Assalem 13 Jan 5, 2023
Clean Android multi-module offline-first scalable app in 2022. Including Jetpack Compose, MVI, Kotlin coroutines/Flow, Kotlin serialization, Hilt and Room.

Android Kotlin starter project - 2022 edition Android starter project, described precisely in this article. Purpose To show good practices using Kotli

Krzysztof Dąbrowski 176 Jan 3, 2023
🦁 A Disney app using transformation motions based on MVVM (ViewModel, Coroutines, Flow, LiveData, Room, Repository, Koin) architecture.

DisneyMotions A demo Disney app using transformation motions based on MVVM architecture. The motion system is included in the 1.2.0-alpha05 released m

Jaewoong Eum 1.4k Jan 2, 2023
Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin Gradle DSL.

SampleCompose Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin

Mohammadali Rezaei 7 Nov 28, 2022
❤️ A sample Marvel heroes application based on MVVM (ViewModel, Coroutines, LiveData, Room, Repository, Koin) architecture.

MarvelHeroes MarvelHeroes is a demo application based on modern Android application tech-stacks and MVVM architecture. Fetching data from the network

Jaewoong Eum 1.2k Dec 19, 2022
Movie Android App written in Kotlin, MVVM, Clean Architechture, Modularized, Coroutines, Android Architecture Components and Hilt

Movie Android App written in Kotlin, MVVM, Clean Architechture, Modularized, Coroutines, Android Architecture Components and Hilt.

Klejvi Kapaj 16 Dec 27, 2022
Basic application that uses Retrofit, Moshi and Coil libraries to parse data from web API

DogAlbum_Api_CodeThrough Basic application that uses Retrofit, Moshi and Coil libraries to parse data from web API This folder contains the completed

Ayana Bando 0 Nov 9, 2021
Showify is a my first simple ✅ Android application 📱 using DI, where I learn how to use dagger-hilt, retrofit2, mvvm, livedata, Requestly Interceptor

Showify is a my first simple ✅ Android application ?? using DI, where I learn how to use dagger-hilt, retrofit2, mvvm, livedata, Requestly Interceptor and so much more...

MOHIT GUPTA 1 Jun 21, 2022
Sample demonstrates use of Flow, StateFlow & how we can test Flow

FlowSample This sample demonstrates use of Flow, StateFlow & how we can test Flow. In Kotlin, Coroutine is just the scheduler part of RxJava but now w

null 0 Oct 24, 2021
My own approach to what I think an Android MVVM project with Clean Architecture should look like with Dagger-Hilt as Dependency Injector engine

MVVM Project Hilt Introducción Este proyecto es mi visión particular, ni mejor ni peor (sólo una más) que cualquier otra aproximación a lo que yo enti

Antonio Fdez. Alabarce 7 Dec 16, 2022
Blog Backend Api built with Kotlin, Springboot and AWS

Kotlin, Spring Boot, MySQL, JPA, Hibernate Rest API for Blogs A Restful CRUD API using Kotlin, Spring Boot, Mysql, JPA and Hibernate hosted on AWS Ela

Nick Ang 1 Nov 15, 2021
This is an example of a simple application with layered software base on clean-architecture as application architecture and mvvm as presentation architecture

This is an example of a simple application with layered software base on clean-architecture as application architecture and mvvm as presentation archi

null 3 Jul 2, 2021
Futurama Quotes demonstrates modern Android development implements MVVM architecture

This application allows you to see futurama quotes. You can search quotes according to the character that said it as well. Futurama Quotes demonstrates modern Android development implements MVVM architecture.

Soumik 2 Apr 28, 2022