android-mvvm-unittest
To learn android MVVM based on Android Architecture Components and unit test.
- Kotlin
β€οΈ - Start with basic and simple.
- Each example should has a unit test at least or more.
E01 - Simple Activity
Simple Data Binding, ViewModel, LiveData on an Activity.
Simple Unit Test with Espresso.
E01a - Simple Activity and Two-way binding
Base on E01
MediatorLiveData to merge events of two LiveData
E02 - Simple Fragment with some animations
Simple Data Binding, ViewModel, LiveData on a Fragment.
Some animations with lottie(resources by Eddy Gann).
Custom binding attribute onAnimationEnd
using
BindingAdapter.
For single Fragment android instrumented test, there is a dummy activity which only works on debug and test that implemented with debug Source set and @RestrictTo annotation.
For unit test, it needs to decouple the logic that getting boolean result from ViewModel. so ViewModelProvider.Factory is here.
E02a - Simple Fragment with some animations and DI library
Based on E02.
Dependency Injection with Kodein DI as a elegant way to decouple the logic.
E03 - RecyclerView
Simple Data Binding,
ViewModel,
LiveData on a RecyclerView
.
Implementation of Add, Remove and Edit actions.
E04 - Request Permission
Request Permission on MVVM.
Transformaions.map to convert strings to a simple format.
MockK for unit test.
E05 - Interaction between 2 Fragments
Reuse E02.
A Fragment knows two ViewModel
, so two views observe one ViewModel
.
ListAdapter for RecyclerView
.
E06 - Infinite RecyclerView
E07 - Change Screen
Using Coordinator for ViewModel
. By doing so, changing screen logic are in one place.