Giter Site home page Giter Site logo

patilshreyas / foodium Goto Github PK

View Code? Open in Web Editor NEW
2.3K 57.0 415.0 18.88 MB

๐Ÿฒ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).

Home Page: https://patilshreyas.github.io/Foodium/

License: MIT License

Kotlin 100.00%
kotlin kotlin-android mvvm mvvm-android android-architecture-components livedata livedata-viewmodel viewbinding room room-persistence-library

foodium's Introduction

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.

foodium's People

Contributors

2307vivek avatar ercan avatar georgcantor avatar naufalprakoso avatar pandubaraja avatar patilshreyas avatar raghunandankavi2010 avatar shubham08gupta avatar sidhu18 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  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

foodium's Issues

Crash happens when tapping on any item.

I am running the app on Nexus 5 android version 6.01 and when on I tap on any item in the food list, instead of showing the detail page, below crash happens:

07-03 21:58:10.930 2289-2289/dev.shreyaspatil.foodium E/AndroidRuntime: FATAL EXCEPTION: main
    Process: dev.shreyaspatil.foodium, PID: 2289
    android.content.res.Resources$NotFoundException: Resource ID #0x7f070080
        at android.content.res.Resources.getValue(Resources.java:1351)
        at androidx.appcompat.widget.ResourceManagerInternal.loadDrawableFromDelegates(ResourceManagerInternal.java:252)
        at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:139)
        at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:132)
        at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:104)
        at androidx.appcompat.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:505)
        at androidx.appcompat.view.menu.ActionMenuItemView.initialize(ActionMenuItemView.java:126)
        at androidx.appcompat.widget.ActionMenuPresenter.bindItemView(ActionMenuPresenter.java:207)
        at androidx.appcompat.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:188)
        at androidx.appcompat.widget.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:193)
        at androidx.appcompat.widget.ActionMenuPresenter.flagActionItems(ActionMenuPresenter.java:473)
        at androidx.appcompat.view.menu.MenuBuilder.flagActionItems(MenuBuilder.java:1182)
        at androidx.appcompat.view.menu.BaseMenuPresenter.updateMenuView(BaseMenuPresenter.java:96)
        at androidx.appcompat.widget.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:226)
        at androidx.appcompat.view.menu.MenuBuilder.dispatchPresenterUpdate(MenuBuilder.java:298)
        at androidx.appcompat.view.menu.MenuBuilder.onItemsChanged(MenuBuilder.java:1069)
        at androidx.appcompat.view.menu.MenuBuilder.startDispatchingItemsChanged(MenuBuilder.java:1096)
        at androidx.appcompat.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:461)
        at androidx.appcompat.app.ToolbarActionBar$1.run(ToolbarActionBar.java:56)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

.idea and apk folders should be ignored by git

It seems .idea folder not ignored by git we need to add it to .gitignore.
Because it will always changes every time we open Android Studio.
It's should be ignored because we don't want to add changes that we are not making.

e.g. misc.xml
Screen Shot 2020-03-25 at 12 56 24

And also apk should not be in repo because if we build it again it will detect it as change. It is unnecessary to put apk in git repo. This will make repo size bigger to clone because we need to download the apk too.

Screen Shot 2020-03-25 at 13 07 34

DARK THEME ISSUE

I had converted ge the theme in to Dark..Then after reopen the theme again going to white.

Add More Screens

Have to add more screens in this app (currently it's single screen app).

  • DetailView - On Clicking blog of MainActivity user should see this screen.

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

dev branch missing

Hi,

Cool project thanks for sharing.

Just checked Contributions guidelines and you mention dev branch but
I guess you 've forgot to push it ?

EDIT: Unless you meant master ?

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

Use room suspending functions

Use room inbuilt support for coroutines
Currently, the code does not use the functionality provided by the Room library. Instead, it uses Dispatchers.IO for threading purposes. I intend to remove this and add inbuilt support.

Proposed changes:
proposed PR

Update README.md

Describe the bug/request
Hi @PatilShreyas
There is a scope of improvements in the README.md file and i would like to update it .
For eg : "This makes it offline capable ๐Ÿ˜ƒ." can be replaced with "This allows us to use it offline ๐Ÿ˜ƒ".
Changes like this will be appealing to the readers and will explain the project in a better manner.
I would like to work on this issue so please can you assign this to me.

Additional context
Add any other context about the problem here.

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,

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

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.

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.