- Saved searches
- Use saved searches to filter your results more quickly
- samadtalukder/Android-Clean-Architecture-MVVM-Kotlin
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Saved searches
- Use saved searches to filter your results more quickly
- hanihussein/MVVM-Kotlin-CleanArchitecture
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Learning Project (Story App) For Applying Android Architecture Components And Clean Architecture Using MVVM With Kotlin. Implemented by Clean Architecture, Hilt, MVVM, LiveData, Coroutines, Retrofit2, Glide
samadtalukder/Android-Clean-Architecture-MVVM-Kotlin
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
This project aims to demonstrate the usage of Android Architecture Components and how this components can be used in an application with a MVVM architecture in Kotlin
Let’s explore Architecture Components
According to Android Documentation, Architecture Components are a set of Android libraries for structuring your app in a way that is robust, testable, and maintainable
- ViewModel has Built in LifeCycleOwerness.
- ViewModel doesn’t have a reference for View.
- ViewModel survive configuration changes (Saving and restoring the UI state).
- Avoid references to Views in ViewModels.
- Instead of pushing data to the UI, let the UI observe changes to it.
- Distribute responsibilities, add a domain layer if needed.
- Add a data repository as the single-point entry to your data.
- Expose information about the state of your data using a wrapper or another LiveData.
- Consider edge cases, leaks and how long-running operations can affect the instances in your architecture.
- Don’t put logic in the ViewModel that is critical to saving clean state or related to data. Any call you make from a ViewModel can be the last one.
- Yes , liveData is easy , powerful , but you should know how to use.
- For livedate which will emit data stream , it has to be in your data layer , and don’t inform those observables any thing else like in which thread those will consume , cause it is another
- For livedata which will emit UI binding events, it has to be in your ViewModel Layer.
It is light wight threads for asynchronous programming, Coroutines not only open the doors to asynchronous programming, but also provide a wealth of other possibilities such as concurrency, actors, etc.
- Writing an asynchronous code is sequential manner.
- Costing of create coroutines are much cheaper to crate threads.
- Don’t be over engineered to use observable pattern, when no need to use it.
- Parent coroutine can automatically manage the life cycle of its child coroutines for you.
About
Learning Project (Story App) For Applying Android Architecture Components And Clean Architecture Using MVVM With Kotlin. Implemented by Clean Architecture, Hilt, MVVM, LiveData, Coroutines, Retrofit2, Glide
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Android Base Sample for latest Android Components and frameworks (Kotlin — Clean archiecture — MVVM — Retrofit — Koin + Coroutines — Mockito — Espresso — Junit)
hanihussein/MVVM-Kotlin-CleanArchitecture
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Android — kotlin — MVVM — Clean Architectural — Koin — Coroutines — Unit Test
It’s a sample project that created by the latest Android technologies and frameworks to be a reference/base for everyone want to start his own project/app much faster.
Brief : sample app consist of two screens:-
Technologies and Frameworks :
Kotlin is an open source programming language for the Java Virtual Machine (JVM). therefore, be used anywhere Java is used today (which is virtually anywhere). This includes server, client, web, and Android development. It’s a light powerful programming languagne.
Design Patterns & Code structure
Clean architecture is a software design paradigm that separates the elements of a design into layers. The main rule of clean architecture is that code dependencies can only come from the outer levels inward. Code on the inner layers can have no knowledge of functions on the outer layers. As below we can see the
- Entities: These are the business objects of the application.
- Use Cases: These use cases orchestrate the flow of data to and from the entities. Are also called Interactors.
- Interface Adapters: This set of adapters convert data from the format most convenient for the use cases and entities. — Presenters and Controllers belong here.
- Frameworks and Drivers: This is where all the details go: UI, tools, frameworks, etc.
Model–view–viewmodel is a software architectural pattern. facilitates a separation of development layers into 3 Layers as following.
- 1- Model Model represents the data and business logic of the app. One of the recommended implementation strategies of this layer, is to expose its data through observables to be decoupled completely from ViewModel or any other observer/consumer.
- 2- Model View ViewModel interacts with model and also prepares observables(Live Data in Android) that can be observed by a View. ViewModel can optionally provide hooks for the view to pass events to the model. One of the important implementation strategies of this layer is to decouple it from the View, i.e, ViewModel should not be aware about the view who is interacting with.
- 3- View (Controllers) the view role in this pattern is to observe (or subscribe to) a ViewModel observable to get data in order to update UI elements accordingly.
Is the powerful lightweight dependency injection framework. Written in pure Kotlin using functional resolution. You create you dependenies graph by yourself . So , you will be aware of all generated code under the hood. You can write more about it here. https://insert-koin.io/
Backgrounds & async Events
Coroutines is A framework to manage concurrency(threads) in a more performant and simple way with its lightweight thread which is written on top of the actual threading framework to get the most out of it by taking the advantage of cooperative nature of functions.
To read more about Coroutines. I strognally recommend this artical Link
The unit test is one of the fundamental parts of the development life cycle. Writing Unit test lets you found and expect uncovered scenarios which we are not thinking about it during development. therefore, you going to cover it and save your clients from face unexpected behavior.
For Android , There’r two types of Testing :-
- Local Test: Unit tests that compile and run locally on JVM. So, no need to a real device Also, it’s not depend on the Android Framework classes. If your tests depend on objects in the Android framework,you have to use Robolectric.
- Instrumented tests: Unit tests that run on an Android device or emulator.
To read more about Unit Testing in Android , check the offical Android tutorial Link
About
Android Base Sample for latest Android Components and frameworks (Kotlin — Clean archiecture — MVVM — Retrofit — Koin + Coroutines — Mockito — Espresso — Junit)