๐Ÿฒ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
A quiz app built with trivia api. This app was built with mvvm architecture, dagger-hilt, retrofit, room database, and navigation components.

A quiz app built with trivia api. This app was built with mvvm architecture, dagger-hilt, retrofit, room database, and navigation components.

Stephen Odumirin 2 Jul 22, 2022
๐Ÿ›’A Minimal Expense E-Commerce App built to demonstrate the use of modern android architecture components [Navigation, Room, MotionLayout, etc..] with MVVM Architecture. โœ”

E-Store A Simple E-Commerce App ?? built to demonstrate the use of modern android architecture component with MVVM Architecture ?? . Made with love โค๏ธ

Ameen Essa 12 Jul 17, 2022
To Do List App is built in Kotlin using Material 3, Data Binding, Navigation Component Graphs, Room persistence library, Kotlin coroutines, LiveData, Dagger Hilt, and Notifications following MVVM Architecture.

ToDoListApp ToDoList App demonstrates modern Android development with Hilt, Coroutines, LiveData, Jetpack (Room, ViewModel), and Material 3 Design bas

Naman Garg 2 Sep 27, 2022
The JeTrivia is built on a modern Android Development tech stack with MVVM architecture. Kotlin, Coroutine, Flow, StateFlow, Jetpack Compose, Navigation, Room, Hilt, Retrofit2, OkHttp3, kotlinx.serialization, MockK, Truth

JeTrivia ?? In Progress ?? The JeTrivia application is sample based on MVVM architecture. Fetching data from the network via repository pattern and sa

Tolga Bolatcan 5 Mar 31, 2022
(Coroutine, Flow(+StateFlow), Hilt, JetPack, MVVM, Repository Pattern, Retrofit2 & OkHttp3, Moshi, Glide, Timber, Material-Components)

(Coroutine, Flow(+StateFlow), Hilt, JetPack, MVVM, Repository Pattern, Retrofit2 & OkHttp3, Moshi, Glide, Timber, Material-Components)

ํ›ˆ์„ฑ 1 Apr 13, 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.3k Oct 3, 2022
An simple image gallery app utilizing Unsplash API to showcase modern Android development architecture (MVVM + Kotlin + Retrofit2 + Hilt + Coroutines + Kotlin Flow + mockK + Espresso + Junit)

Imagine App An simple image gallery app utilizing Unsplash API. Built with โค๏ธŽ by Wajahat Karim and contributors Features Popular photos with paginatio

Wajahat Karim 290 Sep 23, 2022
A Simple Expense Tracker App ๐Ÿ“ฑ built to demonstrate the use of modern android architecture component with MVVM Architecture

Expenso ?? A Simple Expense Tracker App ?? built to demonstrate the use of modern android architecture component with MVVM Architecture ?? . Made with

Michel Horacio 0 Nov 23, 2021
A simple NewsApp built using Jetpack Compose, MVVM Architecture, Dagger Hilt and Kotlin Flow

NewsApp is simple App which uses NewsAPI to get top headlines for country you live in or you can search for a specific news. Focus of this app is to d

ElvisOperator 4 Aug 20, 2022
๐Ÿฆ„ Android Pokedex-AR using ARCore, Sceneform, Hilt, Coroutines, Flow, Jetpack (Room, ViewModel, LiveData) based on MVVM architecture.

?? Android Pokedex-AR using ARCore, Sceneform, Hilt, Coroutines, Flow, Jetpack (Room, ViewModel, LiveData) based on MVVM architecture.

Jaewoong Eum 527 Sep 22, 2022
NewsApp - Modern Minimalistic Design, MVVM, Pagination, Retrofit, Coroutines, Room, Glide, Navigation Component (Clean Architecture)

NewsApp is a modern news android application which features virtually ALL recent and recommended android development tech stack and tools used

Osama Sayed 4 Dec 6, 2021
Small training project where dagger, dagger hilt and other components are used for clean architecture

LeagueNow ?? LeagueNow is a sample soccer team list Android application ?? built to demonstrate use of modern Android development tools - (Kotlin, Arc

Kevin Serrano 1 Oct 21, 2021
Finder Job simple app using (Retrofit , Dagger hilt , coroutines , navigation components)

Job Finder I'm finished building a simple project Job Finder App technology used [dagger hilt, coroutines, navigation components, LiveData, Skelton pa

Gamal Ragab 11 Jun 18, 2022
A Simple and Minimal Quotes Android Application to demonstrate the Modern Android Development tools

Quotee Android ?? A Simple and Minimal Quotes Android Application to demonstrate the Modern Android Development tools. Developed with โค๏ธ by Aminullah

null 12 Aug 24, 2022
Patter Lock using Hilt, Coroutines, Flow and Custom View Components based on MVVM architecture.

Pattern Lock App Sample project for created Pattern Lock View using custom view. Preview Usage Step 1 Add the PatterLockView in your XML layout file.

Furkan ร–zcan 5 Aug 22, 2021
Aplicaciรณn android con MVVM, Room, Retrofit y Dagger Hilt, coonsumiento la API de TMDB.

TMDB Aplicaciรณn android con MVVM, Room, Retrofit y Dagger Hilt, coonsumiento la API de TMDB. To-Do: โ˜‘ Diseรฑo de aplicaciรณn con MVVM e inyeccion de dep

Arturo Herrera 0 Nov 29, 2021
Note taking app using MVVM architecture with Hilt, Material Motion, Coroutines, Flow, Jetpack

Note taking app using MVVM architecture with Hilt, Material Motion, Coroutines, Flow, Jetpack (Room, ViewModel,Paging3).

Ranbir Singh 7 Apr 25, 2022
๐Ÿ”ฅSimple quote app using MVVM, Retrofit, Coroutines and Dagger Hilt ๐Ÿ’‰

?? simple quote app using MVVM, Retrofit, Coroutines and Dagger Hilt ?? quote.mp4 ?? knowledges and technologies ViewBinding Retrofit Coroutines MVVM

Geovani Amaral 4 Aug 26, 2022