AndroidMvvm

Additional

Language
Kotlin
Version
v1.0 (Jan 17, 2019)
Created
Dec 19, 2018
Updated
Jan 18, 2019
Owner
Alexander Shniperson (AlexanderShniperson)
Contributor
Alexander Shniperson (AlexanderShniperson)
1
Activity
Badge
Generate
Download
Source code
APK file

Blurb

AndroidMvvm

Library describes experience how to implement and use of MVVM pattern provided by Google. Project include example of usage.

Library integration

This library is available in JitPack.io repository.

  1. make sure to add the below inside root build.gradle file
allprojects {
    repositories {
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}
  1. add library dependency to the app's build.gradle file.
dependencies {
   implementation 'com.github.AlexanderShniperson:AndroidMvvm:1.0'
}

How to use

  1. Create Fragment with ViewModel from MenuFile > Fragment > Fragment + ViewModel


  2. Put inside your Fragment layout into layout DataBinding tag
<layout>
<FrameLayout>
...
</FrameLayout>
</layout>
  1. Extend your new created Fragment class from MvvmFragment, provide ViewBinding and ViewModel generic classes, implement onMvvmComponentInit method
class NewFragment: MvvmFragment<NewFragmentBinding, NewFragmentViewModel>() {

override fun onMvvmComponentInit() {
  // do any stuff with ViewBinding and ViewModel
}
...
}
  1. Extend your new created ViewModel from MvvmAndroidViewModel
  2. You are done, do any implementations at your ViewModel as described at Sample project