Created
June 29, 2019 17:56
-
-
Save jeremyrempel/79bb987b2608045d425bcfe4476450f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FakeViewModelFactory(private val testviewModel: ViewModel) : ViewModelProvider.Factory { | |
override fun <T : ViewModel?> create(modelClass: Class<T>) = testviewModel as T | |
} | |
| |
class FragFactoryFake(private val viewModel: ViewModel) : FragmentFactory() { | |
override fun instantiate(classLoader: ClassLoader, className: String): Fragment { | |
val fakeViewModelFactory = FakeViewModelFactory(viewModel) | |
return MainFragment(fakeViewModelFactory) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment