viewmodelproviders in kotlin code example
Example 1: viewmodelproviders deprecated
JAVA
replace :
customViewModel = ViewModelProviders.of(this).get(CustomViewModel.class);
with:
customViewModel = new ViewModelProvider(this).get(CustomViewModel.class);
KOTLIN
replace:
customViewModel = ViewModelProviders.of(this).get(CustomViewModel::class.java)
with:
customViewModel = ViewModelProvider(this).get(CustomViewModel::class.java)
Example 2: viewmodelproviders is deprecated
val viewModel = ViewModelProvider(this, YourViewModelFactory).get(YourViewModel::class.java)
val viewModel = ViewModelProvider(this).get(YourViewModel::class.java)